OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Packer_unpacker_benchmark_test.hpp
1/*
2 * Packer_unpacker_benchmark_test.hpp
3 *
4 * Created on: Nov 20, 2016
5 * Author: yaroslav
6 */
7
8#ifndef OPENFPM_DATA_SRC_PACKER_UNPACKER_PACKER_UNPACKER_BENCHMARK_TEST_HPP_
9#define OPENFPM_DATA_SRC_PACKER_UNPACKER_PACKER_UNPACKER_BENCHMARK_TEST_HPP_
10
11/*
12 * benchmark_test.hpp
13 *
14 * Created on: Nov 20, 2016
15 * Author: yaroslav
16 */
17
18BOOST_AUTO_TEST_SUITE( packer_unpacker_benchmark_test )
19
20BOOST_AUTO_TEST_CASE( bm_test )
21{
22 size_t kStringsCount = 100;
23 std::string kStringValue = "shgfkghsdfjhgsfjhfgjhfgjsffghgsfdhgsfdfkdjhfioukjhkfdljgdfkgvjafdhasgdfwurtjkghfsdjkfg";
24
25 openfpm::vector<int64_t> kIntegers = {
26 34492,6603,44033,8874,47607,38416,20395,29192,38620,36775,
27 35058,20501,39664,64574,11261,35679,16607,26020,39476,16699,
28 21505,20947,53587,24746,45980,18827,137,61753,53340,25406,
29 31601,38267,47951,62073,6738,42983,19246,34384,51818,157,
30 628,40807,41177,49445,60677,23663,22312,20616,28922,20389,
31 28543,48407,63986,7216,61601,6647,7956,47434,29257,28162,
32 25582,29941,55019,60580,47503,6662,35851,23648,61464,43188,
33 23519,37727,36778,62597,27203,31950,23796,62866,54914,4507,
34 7775,39256,56141,36388,58687,42619,30909,47784,44209,38712,
35 39387,37342,36743,17467,21181,36301,3918,10068,16204,50558,
36 33633,6164,111,30859,56608,3320,17784,17842,3623,9258,
37 38514,46795,60113,5658,38229,16986,64707,17010,35380,34811,
38 13179,21861,23487,27513,18226,29112,41034,57128,27903,5484,
39 64117,27389,45096,15321,42035,30690,13359,20005,35723,52158,
40 29700,2895,46899,54388,50709,44269,11880,43493,46848,47523,
41 64268,11074,673,62425,10609,21895,65353,51268,30048,8327,
42 15020,13098,8614,9162,44230,34945,49663,35106,37002,13147,
43 23661,47571,58767,27158,58907,18884,29017,49330,21161,20261,
44 22381,57315,11034,39237,35876,52748,52135,3652,5573,11120,
45 35955,16213,32062,32349,26362,7882,39528,40116,378,3620,
46 23121,39308,39836,55477,12003,34089,54450,23870,1952,58445,
47 38567,53959,32265,10354,57972,31510,264,44462,61043,48989,
48 59504,34995,21591,56088,47298,64849,51629,64161,30990,34752,
49 28699,58836,28310,27686,53360,58218,1382,12294,17239,24411,
50 50012,11485,2732,43364,34433,12782,23748,25393,49417,19316,
51 56304,54887,48832,4473,31997,8192,14593,32054,54448,60709,
52 26749,18928,53574,8031,23681,61479,32115,48730,15694,51143,
53 37232,25059,11327,31269,18035,24905,30575,35576,50878,63566,
54 7213,10140,13121,13487,53861,3487,58552,11636,42412,59239,
55 38086,16738,16197,45757,47844,18248,14385,64858,2785,43969,
56 55873,34166,42623,15441,55015,9219,47800,3659,47139,54900,
57 36120,23551,51858,64110,44719,51319,17756,56240,44986,22746,
58 4944,50980,43252,4881,53006,12039,41658,49870,54730,10213,
59 15296,9139,54583,7345,10260,58177,4126,46487,15644,1323,
60 7767,40475,61334,33814,296,4202,58954,60710,47287,17842,
61 62948,40443,16982,64708,45849,58300,16400,20536,38687,3543,
62 14340,17591,37874,58282,12109,61025,17392,4014,39117,40912,
63 24572,39998,57703,4373,28314,27751,11307,43386,28218,4223,
64 10843,46516,48966,472,54111,55663,33428,52509,3845,5647,
65 3164,36542,16868,5700,44693,1240,12757,22308,12715,9024,
66 11999,42661,57211,50848,14944,59955,59208,41264,20033,23019,
67 6368,43478,48738,14758,41280,24076,64014,52013,24937,46899,
68 59046,52457,22428,27505,43159,17779,26304,23403,52731,32394,
69 11878,6003,29789,43818,59314,20329,58069,13081,61424,27718,
70 29996,21610,3205,14477,37523,35003,36286,62906,44191,31058,
71 53068,826,49309,1705,44214,29908,19433,61948,46663,42710,
72 15534,7807,36492,51075,56749,56906,28946,10316,12099,38561,
73 41455,12573,42613,18640,64463,61175,61712,57225,10181,60007,
74 49094,30559,59477,48603,15646,56068,58417,29704,40969,37530,
75 18769,35771,62828,64452,43719,35415,9679,48100,37102,2014,
76 37901,40564,5231,35279,31257,46681,36297,49026,30314,53309,
77 1772,15145,34777,28019,28568,11004,55343,63726,32528,7595,
78 7288,61637,55329,11723,41610,36885,34524,9144,58781,31381,
79 31576,51243,65449,3883,24602,41301,49332,30071,24731,53076,
80 18835,30948,31196,15758,58879,8007,16244,56729,31879,13324,
81 30246,59487,40604,41656,9922,16564,41094,26477,14418,47704,
82 46087,43602,35364,3468,28154,40737,22138,29789,22868,29611,
83 137,18409,26366,11641,24154,33214,53316,54678,56564,6485,
84 63859,30593,23819,63569,40255,28125,3821,58358,26034,27326,
85 20168,39097,34762,3861,54465,48588,41685,9521,42716,60424,
86 61811,64517,55711,28716,5876,16802,43184,32158,12460,33802,
87 43630,57941,65454,57092,23134,1757,42449,56716,47808,31003,
88 52358,59607,60476,14763,48276,61767,52541,15148,59109,60993,
89 8607,56930,13760,52036,4132,61711,4915,59651,11062,750,
90 32426,26748,61727,1006,38136,15828,5934,5901,37067,46827,
91 11884,17393,6322,58799,45596,60370,61443,46045,64246,48987,
92 2765,29446,10923,21875,48410,39056,42986,5562,17903,63126,
93 57165,16031,63190,41857,20363,25337,60583,34165,12117,31144,
94 15233,32201,50866,19101,22325,45683,41215,28885,42919,56843,
95 26045,18702,32409,4802,11310,50435,18268,34070,56862,48307,
96 27179,35722,23159,5270,62523,55928,37842,1469,52744,63149,
97 61265,28590,10318,36834,31225,55332,26967,34844,53898,13550,
98 45088,18743,10663,64974,29124,42159,34634,3895,22055,5649,
99 53895,30439,38264,18351,980,62663,5479,32694,2392,14157,
100 34319,34875,42709,52995,35927,63947,62191,63907,24903,15705,
101 40955,50782,64934,62454,19404,53365,25945,57405,41221,12921,
102 34291,15944,32298,4083,30010,44032,41316,28130,31221,18940,
103 44513,5513,24837,54233,9899,39933,29068,23247,47440,52698,
104 63372,8945,51493,57120,52514,20487,60260,59814,1484,24789,
105 33866,45112,14526,60221,50973,25125,5991,48481,33017,59821,
106 42654,51735,63141,55833,14490,35443,44171,62286,36815,23160,
107 32977,31387,20525,49812,1295,43744,18217,34480,58203,61045,
108 25528,48777,55709,47339,37999,49039,45022,35884,33880,44348,
109 1526,6778,14068,16467,699,3820,2828,55811,62784,22958,
110 21898,18678,15946,42931,47002,933,19312,32862,25994,6791,
111 58533,15443,21048,11212,28899,9618,9053,61352,45516,23407,
112 35256,58880,36406,36544,6981,30273,65302,37871,10065,19591,
113 6464,15831,40594,62620,61300,39313,57367,56539,21501,61070,
114 13632,27764,60371,47978,38670,33853,31205,49260,56140,18928,
115 27245,47480,45291,64421,19547,29616,38608,45751,62137,18789,
116 59923,25449,57664,9889,18109,26588,20278,51672,21209,23202,
117 29419,55090,35147,32818,15270,49125,30648,64720,29814,57758,
118 25352,11149,3703,16912,60520,34110,42527,1438,36294,17877,
119 52345,28849,16183,34088,37493,39997,54697,970,14983,60268,
120 19566,32131,54265,10366,49778,1520,43174,34006,64401,58034,
121 35005,27621,65337,58940,9671,6424,61857,22542,30725,61777,
122 12539,29197,24034,28450,2769,41642,50160,47847,18152,51053,
123 47843,61836,25260,36400,22250,17010,29460,51714,42262,28230,
124 54088,34531,17424,36588,53806,32847,11804,28344,16504,38941,
125 23441,53703,31551,61990,59981,19355,32417,16169,64680,1600
126 };
127
128 size_t num1 = 5;
129 size_t num2 = 10;
131
132 for (size_t n = 0; n < num1; n++)
133 {
134 //Timer
135 timer t;
136 t.start();
137 for (size_t i = 0; i < num2; i++) {
138 size_t req = 0;
139
140 //Pack requesting
141
142 Packer<decltype(kStringsCount),HeapMemory>::packRequest(kStringsCount,req);
143 Packer<decltype(kIntegers),HeapMemory>::packRequest(kIntegers,req);
144 //Packer<decltype(kStringValue),HeapMemory>::packRequest(kStringValue,req);
145
146
147 // allocate the memory
148 HeapMemory pmem;
149 //pmem.allocate(req);
150 ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(req,pmem));
151 mem.incRef();
152
153 //Packing
154 Pack_stat sts;
155
156 Packer<decltype(kStringsCount),HeapMemory>::pack(mem,kStringsCount,sts);
157 Packer<decltype(kIntegers),HeapMemory>::pack(mem,kIntegers,sts);
158 //Packer<decltype(kStringValue),HeapMemory>::pack(mem,kStringValue,sts);
159
160
161 //Unpacking
162 Unpack_stat ps;
163
164 std::string kStringValueUnp;
165 kStringValueUnp.resize(86);
166 openfpm::vector<int64_t> kIntegersUnp;
167
168 Unpacker<decltype(kStringsCount),HeapMemory>::unpack(mem,kStringsCount,ps);
169 Unpacker<decltype(kIntegersUnp),HeapMemory>::unpack(mem,kIntegersUnp,ps);
170 //Unpacker<decltype(kStringValueUnp),HeapMemory>::unpack(mem,kStringValueUnp,ps);
171 }
172 t.stop();
173
174 time.add(t.getwct());
175 }
176
177 double sum = 0;
178 for (size_t m = 0; m < time.size(); m++)
179 sum += time.get(m);
180
181}
182
183BOOST_AUTO_TEST_SUITE_END()
184
185#endif /* OPENFPM_DATA_SRC_PACKER_UNPACKER_PACKER_UNPACKER_BENCHMARK_TEST_HPP_ */
virtual void incRef()
Increment the reference counter.
This class allocate, and destroy CPU memory.
Packing status object.
Definition Pack_stat.hpp:61
Packing class.
Definition Packer.hpp:50
Unpacking status object.
Definition Pack_stat.hpp:16
Unpacker class.
Definition Unpacker.hpp:34
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.
Class for cpu time benchmarking.
Definition timer.hpp:28
void stop()
Stop the timer.
Definition timer.hpp:119
void start()
Start the timer.
Definition timer.hpp:90
double getwct()
Return the elapsed real time.
Definition timer.hpp:130
It model an expression expr1 + ... exprn.
Definition sum.hpp:93