[zeromq-dev] STL use in zeromq

Mikael Helbo Kjær mhk at designtech.dk
Fri Oct 29 13:21:15 CEST 2010


Hi 

I ran a test of the concepts as I described them (had to correct an
issue that made microsofts STL go nuts over iterator invalidation as
usual when erasing). And the erase-remove idiom is an order of
magnitude faster. I am surprised at the great difference.
 
On an average of just 10 runs (not enough to statistically relevant I
know, but the values don't deviate a lot so...) the current zmq way of
doing things takes ~50s to remove approximate 100000 values from a
1000000 vector of pseudo-random integer values.
 
In the same situation with the same vector sizes the erase-remove idiom
takes around 900 milliseconds.
 
This test was done on a Core i7 64-bit Windows 7 with a binary produced
by Visual Studio 2008. A VS2010 might have been faster as the STL there
can or will soon use rvalue references to improve swap/move operations.
I don't have a GCC test ready, but I could supply the short C++ unit
test I implemented (edited slightly to remove the usage of my unit test
framework and the like) if anyone is remotely interested.
 
I am sure most vectors in 0mq are much much shorter than this but if
there are places where there is a lot of incoming and outgoing messages
maybe the erase-remove idiom might be useful there.
 
Regards,
Mikael



More information about the zeromq-dev mailing list