
On February 21, 2014 3:12:08 AM EST, Vladimir Batov
Rob Stewart
writes: On February 20, 2014 6:27:42 PM EST, Vladimir Batov
wrote: I am especially surprised by the fact that its performance seems quite adequate (without any optimization): [snip] tests. On the other hand the test could not be any more straightforward:
[snip]
I assume you're timing an optimized build, on which case you are being misled by the optimizer because you're not using the results of the conversions.
Rob,
Nice hearing from you. I had that suspicion also and I do not think optimization was at play. The reason is that I timed twice with "-g" and without and definitely did not have optimization flags (never use them). And it's hard not to notice when the code is optimized -- stepping through is, well, difficult. :-)
Using -g simply includes symbols. It has nothing to do with optimizations. Not testing with optimizations is not worthwhile. sprintf() is highly tuned and C++ code relies on inlining, copy elision, etc. Users of your library will certainly use it with optimizations.
Secondly, my actual code is different (for the post I cut it to bare minimum). All loops are actually like
for (int k = 0; k < local::num_cycles; ++k) { int k = boost::convert<int>::from("12345", ccnv).value(); BOOST_ASSERT(k == 12345); }
Do you think there still might be something I missed?
The assertion won't help in an optimized build, of course. Save the values and print them at the end, after you've captured the elapsed times. ___ Rob (Sent from my portable computation engine)