http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53263
Bug #: 53263 Summary: priority_queue is very slow if -D_GLIBCXX_DEBUG is used Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: dominik.stras...@onespin-solutions.com Created attachment 27332 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27332 Minimalistic example demonstrating the problem I've measured the most simplistic usage of priority queue. With 5,000 elements, the run time is: real 0m0.005s user 0m0.002s sys 0m0.002s With 10,000 elements, the run time is: real 0m0.006s user 0m0.002s sys 0m0.002s If I switch on -D_GLIBCXX_DEBUG, the situation changes: 5,000 elements: real 0m11.216s user 0m11.210s sys 0m0.003s 10,000 elements: real 0m48.354s user 0m48.344s sys 0m0.003s 20,000 elements: real 2m56.971s user 2m56.941s sys 0m0.002s So in addition to some overhead, there seems to be some quadratic behavior inside the debug version as the run time is 4x for 2x elements.