Matus Chochlik wrote
str-to-int spirit: raw/cnv=1.44/1.41 seconds. str-to-int spirit: raw/cnv=1.44/1.41 seconds.
That is, gcc-4.8 applies some magic so that that same code wrapped in a converter is 2% faster(!) than "raw" code. Is anyone curious and capable to solve the puzzle? I am admittedly the former but not the latter. :-(
https://github.com/yet-another-user/boost.convert/ blob/master/test/performance.cpp
IMHO this could have something to do with paging or the caching of the strings. You should test the two cases by two separate programs and try to run them both in the raw then cnv and cnv then raw orders. Or you could at least try to run
for (int k = 0; k < 3; ++k) printf("str-to-int spirit: raw1/raw2=%.2f/%.2f seconds.\n", performance_string_to_int_spirit(strings), performance_string_to_int_spirit(strings));
to try it out.
Matus, Geez, I would never figure that out by myself. Thanks. So, the first call would pull the strings into the fast cache so that the second call would not have to, right? Now I changed the test as int const num_tries = 20; double raw_time = 0; double cnv_time = 0; for (int k = 0; k < num_tries; ++k) raw_time += performance_string_to_int_spirit(strings); for (int k = 0; k < num_tries; ++k) cnv_time += performance::str_to_int(strings, boost::cnv::spirit()); printf("str-to-int spirit: raw/cnv=%.2f/%.2f seconds.\n", raw_time / num_tries, cnv_time / num_tries); Does it look fair to you? It surely gives more realistic results with bosst::convert() adding 0.7% overhead: 32:~/dev/boost.convert.>> ~/dev/bin/test-convert str-to-int spirit: raw/cnv=1.41/1.42 seconds. -- View this message in context: http://boost.2283326.n4.nabble.com/review-Convert-library-tp4662821p4663911.... Sent from the Boost - Dev mailing list archive at Nabble.com.