KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When comparing two variants of pointers—classic vs. shared_ptr—I was surprised by a significant increase of the running speed of the program. For testing 2D Delaunay incremental Insertion algorithm has been used. Compiler settings: VS 2010 (release) /O2 /MD /GL, W7 Prof, CPU 3.GHZ DualCore Results: shared_ptr (C++ 0x00): N[points] t[sec] 100 000 6 200 000 11 300 000 16 900 000 36 Pointers: N[points] t[sec] 100 000 0,5 200 000 1 300 000 2 900 000 4 Running time of the shared_ptr versions is approximately 10 times longer. Is this caused by the compiler settings or C++ 0x00 shared_ptr implementation is so slow? VS2010 Profiler: For raw pointers about 60% of the time is spent by heuristic searching of the triangle containing inserted point (it is OK, it is a well-known fact). But for the shared_ptr version approx 58% of the time is spent using shared_ptr.reset() and only 10% is used for heuristic searching. Testing code with raw pointers: void DT2D::DT ( Node2DList *nl, HalfEdgesList *half_edges_dt, bool print ) { // Create 2D Delaunay triangulation using incremental insertion method unsigned int nodes_count_before = nl->size(); // Remove duplicit points nl->removeDuplicitPoints(); // Get nodes count after deletion of duplicated points unsigned int nodes_count_after = nl->size(); //Print info std::cout << "> Starting DT, please wait... "; std::cout << nodes_count_after << " points, " << ( nodes_count_before - nodes_count_after ) << " removed."; // Are in triangulation more than three points try { //There are at least 3 points if (
Tags (comma-separated)
Save Edits
Cancel