Am 21.09.2016 um 19:36 schrieb Bjorn Reese:
On 09/21/2016 06:35 PM, Georg Gast wrote:
Now i can see bigger differences, but its still slower much than cstyle.
The Boost archives use iostreams, whereas cstyle uses memcpy.
Yes, thats clear. :)
After watching "CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks,
and CPUs, and Compilers! Oh My!" [1] i used on linux the
google/benchmark [2] library to measure more precise.
[1] https://www.youtube.com/watch?v=nXaxk27zwlk
[2] https://github.com/google/benchmark
This seems to be much better to judge the performance.
I let each test run for at least 10 seconds.
-----------------------------------------------------
Linux x64 gcc 6.1.1
Benchmark Time(ns) CPU(ns) Iterations
-------------------------------------------------
to_wire_xml 16073 16072 872818
to_wire_text 14413 14409 997151
to_wire_binary 10384 10520 1268116
to_wire_cstyle 218 218 63405797
from_wire_xml 32202 32209 434783
from_wire_text 13322 13320 1023392
from_wire_binary 9906 9906 1402806
from_wire_cstyle 210 210 66666667
-----------------------------------------------------
-----------------------------------------------------
Win 10 x64 MSVC 2015
Benchmark Time(ns) CPU(ns) Iterations
-------------------------------------------------
to_wire_xml 84145 84027 173308
to_wire_text 54691 54751 250279
to_wire_binary 44086 44028 315493
to_wire_cstyle 110 110 126197183
from_wire_xml 97023 96801 143820
from_wire_text 51315 51250 273171
from_wire_binary 43359 43408 320000
from_wire_cstyle 103 103 135757576
-----------------------------------------------------
My opinion: gcc is better at optimizing.... This must be the reason why
windows is slower at the archives.
-----------------------------------------------------
The code
-----------------------------------------------------
static void to_wire_xml(benchmark::State& state)
{
while (state.KeepRunning())
{
boost_test