Floating Sun » stl http://floatingsun.net Mon, 07 Jan 2013 02:53:26 +0000 en-US hourly 1 http://wordpress.org/?v=3.5.1 STL is Slow Template Library http://floatingsun.net/2006/10/19/stl-is-slow-template-library/?utm_source=rss&utm_medium=rss&utm_campaign=stl-is-slow-template-library http://floatingsun.net/2006/10/19/stl-is-slow-template-library/#comments Thu, 19 Oct 2006 17:33:01 +0000 Diwaker Gupta http://floatingsun.net/blog/2006/10/19/760/ Related posts:
  1. Slow nooooo!
  2. The ACM Digital Library badly needs an overhaul
  3. Slow
]]>

The C++ Standard Template Library (STL) can be pretty intimidating. I used to think that there’s a lot of magic under the covers to make things go really fast. It turns out that while using the STL is convinient for prototype, its not really built for performance.

A few days back, we needed to do some //compare-by-hash// operations on two files. In all we were doing around 32 million hash table lookups (plus of course the overhead of computing the hash values themselves). On a reasonably fast machine, one would expect that 32 million operations shouldn’t take very long. However, this particular program ran for one **whole day**.

Then Amin suggested that we rip out the STL stuff and just work with a statically allocated hash table since we weren’t really concerned about memory management at this stage. And guess what, the runtime fell to around **10 minutes**. Thats //two orders of magnitude// performance improvement!! I had never imagined that the STL could be //soo// slow.

]]>
http://floatingsun.net/2006/10/19/stl-is-slow-template-library/feed/ 11