febird.dataio vs boost.serialization 运行性能对比

代码表示的是数据格式,DATA_IO_LOAD_SAVE 在 <febird/io/DataIO.h> 中定义

对boost,DATA_IO_LOAD_SAVE 的定义相当于:

#define DATA_IO_LOAD_SAVE(Class, Members) \

    friend class boost::serialization::access; \

    template<class Archive> \

    void serialize(Archive & ar, const unsigned int version) \

    { ar Members; }

 

数据格式:

 

struct MyData1

{

    uint32_t a, b, c;

    uint32_t d[5];

    DATA_IO_LOAD_SAVE(MyData1, &a&b&c&d)

};

 

struct MyData2

{

    uint32_t a, b, c, d;

    MyData1 e;

DATA_IO_LOAD_SAVE(MyData2, &a&b&c&d&e)

};

 

struct MyData3

{

    uint32_t a, b, c;

    uint32_t d;

};

DATA_IO_DUMP_RAW_MEM(MyData3)

 

struct VarIntD

{

    var_uint32_t a, b, c, d, e, f;

 

    VarIntD()

    {

        a = 127;

        b = 128;

        c = 128*128;

        d = 128*128*128;

        e = 128*128*128*128;

        f = 1;

    }

    DATA_IO_LOAD_SAVE(VarIntD, &a&b&c&d&e&f)

};

typedef pair<MyData2, MyData3> MyData23; 

 

boost_bin_save: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[   1004,    1004,    1.0000]
    vector<MyData1>       .size= 4000, time[  23918,   23918,    1.0000]
    vector<string>        .size= 4000, time[   9266,    9266,    1.0000]
    map<int,string>       .size= 3756, time[  19434,   19434,    1.0000]
    loop{MyData1 },  loop count= 4000, time[  23592,   23592,    1.0000]
    loop{VarIntD },  loop count= 4000, time[  52832,   52832,    1.0000]
    vector<MyData23>,     .size= 4000, time[  68581,   68581,    1.0000]

boost_bin_load: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    766,     766,    1.0000]
    vector<MyData1>       .size= 4000, time[  26738,   26738,    1.0000]
    vector<string>        .size= 4000, time[  41097,   41097,    1.0000]
    map<int,string>       .size= 3756, time[  63985,   63985,    1.0000]
    loop{MyData1 },  loop count= 4000, time[  23486,   23486,    1.0000]
    loop{VarIntD },  loop count= 4000, time[  88218,   88218,    1.0000]
    vector<MyData23>,     .size= 4000, time[  75386,   75386,    1.0000]

File Save Native: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    593,    1004,    1.6910]
    vector<MyData1>       .size= 4000, time[   1043,   23918,   22.9288]
    vector<string>        .size= 4000, time[   3741,    9266,    2.4767]
    map<int,string>       .size= 3756, time[   5018,   19434,    3.8723]
    loop{MyData1 },  loop count= 4000, time[   2898,   23592,    8.1390]
    loop{VarIntD },  loop count= 4000, time[   8664,   52832,    6.0977]
    vector<MyData23>,     .size= 4000, time[   5768,   68581,   11.8887]

File Load Native: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    400,     766,    1.9156]
    vector<MyData1>       .size= 4000, time[    868,   26738,   30.7855]
    vector<string>        .size= 4000, time[   3812,   41097,   10.7790]
    map<int,string>       .size= 3756, time[  58671,   63985,    1.0906]
    loop{MyData1 },  loop count= 4000, time[   1547,   23486,   15.1780]
    loop{VarIntD },  loop count= 4000, time[   2580,   88218,   34.1866]
    vector<MyData23>,     .size= 4000, time[   4667,   75386,   16.1499]

File Save Portable: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[   1114,    1004,    0.9010]
    vector<MyData1>       .size= 4000, time[   4044,   23918,    5.9143]
    vector<string>        .size= 4000, time[   3480,    9266,    2.6628]
    map<int,string>       .size= 3756, time[   5089,   19434,    3.8185]
    loop{MyData1 },  loop count= 4000, time[   3622,   23592,    6.5132]
    loop{VarIntD },  loop count= 4000, time[   7255,   52832,    7.2812]
    vector<MyData23>,     .size= 4000, time[   6831,   68581,   10.0397]

File Load Portable: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    500,     766,    1.5318]
    vector<MyData1>       .size= 4000, time[   1543,   26738,   17.3266]
    vector<string>        .size= 4000, time[   3924,   41097,   10.4728]
    map<int,string>       .size= 3756, time[  58689,   63985,    1.0902]
    loop{MyData1 },  loop count= 4000, time[   2957,   23486,    7.9425]
    loop{VarIntD },  loop count= 4000, time[   2575,   88218,   34.2497]
    vector<MyData23>,     .size= 4000, time[   5375,   75386,   14.0246]

Memory Save Native: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    198,    1004,    5.0705]
    vector<MyData1>       .size= 4000, time[    510,   23918,   46.8615]
    vector<string>        .size= 4000, time[   3088,    9266,    2.9999]
    map<int,string>       .size= 3756, time[   3679,   19434,    5.2817]
    loop{MyData1 },  loop count= 4000, time[   1106,   23592,   21.3311]
    loop{VarIntD },  loop count= 4000, time[   7546,   52832,    7.0006]
    vector<MyData23>,     .size= 4000, time[   2242,   68581,   30.5868]

Memory Load Native: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    170,     766,    4.4853]
    vector<MyData1>       .size= 4000, time[    505,   26738,   52.9088]
    vector<string>        .size= 4000, time[   3134,   41097,   13.1104]
    map<int,string>       .size= 3756, time[  58097,   63985,    1.1013]
    loop{MyData1 },  loop count= 4000, time[    114,   23486,  205.5526]
    loop{VarIntD },  loop count= 4000, time[   4586,   88218,   19.2339]
    vector<MyData23>,     .size= 4000, time[   1894,   75386,   39.7889]

Memory Save Portable: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    557,    1004,    1.8029]
    vector<MyData1>       .size= 4000, time[   2392,   23918,    9.9960]
    vector<string>        .size= 4000, time[   2916,    9266,    3.1778]
    map<int,string>       .size= 3756, time[   3563,   19434,    5.4539]
    loop{MyData1 },  loop count= 4000, time[   2203,   23592,   10.7061]
    loop{VarIntD },  loop count= 4000, time[   7307,   52832,    7.2294]
    vector<MyData23>,     .size= 4000, time[   3742,   68581,   18.3243]

Memory Load Portable: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    301,     766,    2.5464]
    vector<MyData1>       .size= 4000, time[   1182,   26738,   22.6056]
    vector<string>        .size= 4000, time[   3150,   41097,   13.0453]
    map<int,string>       .size= 3756, time[  57657,   63985,    1.1098]
    loop{MyData1 },  loop count= 4000, time[   1549,   23486,   15.1589]
    loop{VarIntD },  loop count= 4000, time[   4610,   88218,   19.1325]
    vector<MyData23>,     .size= 4000, time[   2650,   75386,   28.4410]

Uncheck Save Native: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    173,    1004,    5.7797]
    vector<MyData1>       .size= 4000, time[    480,   23918,   49.8057]
    vector<string>        .size= 4000, time[   2480,    9266,    3.7358]
    map<int,string>       .size= 3756, time[   3436,   19434,    5.6552]
    loop{MyData1 },  loop count= 4000, time[   1070,   23592,   22.0381]
    loop{VarIntD },  loop count= 4000, time[   7110,   52832,    7.4300]
    vector<MyData23>,     .size= 4000, time[   2155,   68581,   31.8240]

Uncheck Load Native: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    172,     766,    4.4489]
    vector<MyData1>       .size= 4000, time[    530,   26738,   50.3747]
    vector<string>        .size= 4000, time[   2985,   41097,   13.7681]
    map<int,string>       .size= 3756, time[  57228,   63985,    1.1181]
    loop{MyData1 },  loop count= 4000, time[     17,   23486, 1355.9839]
    loop{VarIntD },  loop count= 4000, time[   2472,   88218,   35.6816]
    vector<MyData23>,     .size= 4000, time[   1838,   75386,   40.9979]

Uncheck Save Portable: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    518,    1004,    1.9359]
    vector<MyData1>       .size= 4000, time[   2415,   23918,    9.9001]
    vector<string>        .size= 4000, time[   2430,    9266,    3.8126]
    map<int,string>       .size= 3756, time[   3599,   19434,    5.3985]
    loop{MyData1 },  loop count= 4000, time[   2037,   23592,   11.5812]
    loop{VarIntD },  loop count= 4000, time[   7476,   52832,    7.0660]
    vector<MyData23>,     .size= 4000, time[   3740,   68581,   18.3325]

Uncheck Load Portable: loop=10, time[febird, boost, ratio=b/f] in us
    vector<pair<int,int> >.size= 4000, time[    281,     766,    2.7232]
    vector<MyData1>       .size= 4000, time[   1199,   26738,   22.2897]
    vector<string>        .size= 4000, time[   2731,   41097,   15.0437]
    map<int,string>       .size= 3756, time[  57136,   63985,    1.1199]
    loop{MyData1 },  loop count= 4000, time[   1578,   23486,   14.8825]
    loop{VarIntD },  loop count= 4000, time[   2628,   88218,   33.5581]
    vector<MyData23>,     .size= 4000, time[   2420,   75386,   31.1459]

 

项目地址:http://code.google.com/p/febird

你可能感兴趣的:(C++,c,C#,F#,Google)