Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Runtime overhead of serialization archives
From: Georg Gast (georg_at_[hidden])
Date: 2016-09-21 14:35:58


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<boost_xml_trait>::to_wire(ev_test());
        }
}
BENCHMARK(to_wire_xml);

static void to_wire_text(benchmark::State& state)
{
        while (state.KeepRunning())
        {
                boost_test<boost_text_trait>::to_wire(ev_test());
        }
}
BENCHMARK(to_wire_text);

static void to_wire_binary(benchmark::State& state)
{
        while (state.KeepRunning())
        {
                boost_test<boost_binary_trait>::to_wire(ev_test());
        }
}
BENCHMARK(to_wire_binary);

static void to_wire_cstyle(benchmark::State& state)
{
        while (state.KeepRunning())
        {
                cstyle_test::to_wire(ev_test());
        }
}
BENCHMARK(to_wire_cstyle);

static void from_wire_xml(benchmark::State& state)
{
        auto buffer = boost_test<boost_xml_trait>::to_wire(ev_test());
        
        while (state.KeepRunning())
        {
                boost_test<boost_xml_trait>::from_wire(buffer);
        }
}
BENCHMARK(from_wire_xml);

static void from_wire_text(benchmark::State& state)
{
        auto buffer = boost_test<boost_text_trait>::to_wire(ev_test());
        
        while (state.KeepRunning())
        {
                boost_test<boost_text_trait>::from_wire(buffer);
        }
}
BENCHMARK(from_wire_text);

static void from_wire_binary(benchmark::State& state)
{
        auto buffer = boost_test<boost_binary_trait>::to_wire(ev_test());
        
        while (state.KeepRunning())
        {
                boost_test<boost_binary_trait>::from_wire(buffer);
        }
}
BENCHMARK(from_wire_binary);

static void from_wire_cstyle(benchmark::State& state)
{
        auto buffer = cstyle_test::to_wire(ev_test());
        
        while (state.KeepRunning())
        {
                cstyle_test::from_wire(buffer);
        }
}
BENCHMARK(from_wire_cstyle);

-- 
pgp key: 0x702C5BFC
Fingerprint: 267F DC06 7F96 3375 969A  9EE6 8E37 7CF4 702C 5BFC

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net