help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: perfomance of clear vs swap


From: Krishanu Debnath
Subject: Re: perfomance of clear vs swap
Date: Fri, 01 Dec 2006 12:56:35 +0530
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Paul Pluzhnikov wrote:
krishanu.debnath@gmail.com writes:

I have a call to hash_map::clear() function which takes long time.

It is somewhat likely that you are mis-interpreting the results
that you observed.

It is hard to imagine a situation in which creating a hash_map
takes less time than clear()ing it.

I admit this is a corner case.


Using g++4.0.0, creating a 10,000,000 entry hash_map takes 116
seconds on my machine; clearing via either clear() or swap() with
temporary takes 8 seconds.

Now runtime drops significantly, 10 fold less.
What's exactly cause this run time reduction?

User error, most likely.

If you are convinced that you really see what you claim to see,
post a complete compilable test case that demonstrates that.

Cheers,

I will once I get free time. :-)
You may be interested on the discussion going on comp.lang.c++.moderated.

http://groups.google.co.in/group/comp.lang.c++.moderated/browse_frm/thread/db399126443f69e7/c44bac7e9547a6f0?lnk=st&q=clear+vs+swap&rnum=1&hl=en#c44bac7e9547a6f0


Krishanu


reply via email to

[Prev in Thread] Current Thread [Next in Thread]