Debian Codegraph @

doc/benchmarks.rst

raw
1 .. raw:: html
2
3 <style> .red {color:red} </style>
4 <style> .blue {color:blue} </style>
5 <style> .green {color:green} </style>
6 <style> .cyan {color:cyan} </style>
7 <style> .magenta {color:magenta} </style>
8 <style> .orange {color:orange} </style>
9 <style> .brown {color:brown} </style>
10
11 .. role:: red
12 .. role:: blue
13 .. role:: green
14 .. role:: cyan
15 .. role:: magenta
16 .. role:: orange
17 .. role:: brown
18
19 ----------
20 Benchmarks
21 ----------
22
23
24 Test setup
25 ==========
26
27 The benchmarks were done using two test files (available `here <https://github.com/danielhrisca/asammdf/issues/14>`_) (for mdf version 3 and 4) of around 170MB.
28 The files contain 183 data groups and a total of 36424 channels.
29
30 *asamdf 8.8.0* was compared against *mdfreader 4.2*.
31
32 For each category two aspect were noted: elapsed time and peak RAM usage.
33
34 Dependencies
35 ------------
36 You will need the following packages to be able to run the benchmark script
37
38 * psutil
39 * mdfreader
40
41 Usage
42 -----
43 Extract the test files from the archive, or provide a folder that contains the files "test.mdf" and "test.mf4".
44 Run the module *bench.py* ( see --help option for available options )
45
46
47 x64 Python results
48 ==================
49
50 Benchmark environment
51
52 * 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]
53 * Windows-11-10.0.26200-SP0
54 * AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
55 * numpy 2.4.3
56 * 15GB installed RAM
57
58 Notations used in the results
59
60 * compress = mdfreader mdf object created with compression=blosc
61 * nodata = mdfreader mdf object read with no_data_loading=True
62
63 Files used for benchmark:
64
65 * mdf version 3.10
66 * 167 MB file size
67 * 183 groups
68 * 36424 channels
69 * mdf version 4.00
70 * 183 MB file size
71 * 183 groups
72 * 36424 channels
73
74
75
76 ================================================== ========= ========
77 Open file Time [ms] RAM [MB]
78 ================================================== ========= ========
79 asammdf 8.8.0 mdfv3 313 215
80 mdfreader 4.2 mdfv3 1785 523
81 mdfreader 4.2 no_data_loading mdfv3 644 252
82 mdfreader 4.2 compress mdfv3 1369 389
83 asammdf 8.8.0 mdfv4 449 228
84 mdfreader 4.2 mdfv4 3513 544
85 mdfreader 4.2 no_data_loading mdfv4 2348 288
86 mdfreader 4.2 compress mdfv4 3326 413
87 ================================================== ========= ========
88
89
90 ================================================== ========= ========
91 Save file Time [ms] RAM [MB]
92 ================================================== ========= ========
93 asammdf 8.8.0 mdfv3 319 373
94 mdfreader 4.2 mdfv3 6241 548
95 mdfreader 4.2 no_data_loading mdfv3 6859 600
96 mdfreader 4.2 compress mdfv3 6432 546
97 asammdf 8.8.0 mdfv4 456 395
98 mdfreader 4.2 mdfv4 10259 562
99 mdfreader 4.2 no_data_loading mdfv4 4174 611
100 mdfreader 4.2 compress mdfv4 1791 558
101 ================================================== ========= ========
102
103
104 ================================================== ========= ========
105 Get all channels (36424 calls) Time [ms] RAM [MB]
106 ================================================== ========= ========
107 asammdf 8.8.0 mdfv3 1536 376
108 mdfreader 4.2 mdfv3 35 523
109 mdfreader 4.2 nodata mdfv3 14466 286
110 mdfreader 4.2 compress mdfv3 109 389
111 asammdf 8.8.0 mdfv4 7820 394
112 mdfreader 4.2 mdfv4 45 543
113 mdfreader 4.2 nodata mdfv4 18291 312
114 mdfreader 4.2 compress mdfv4 113 415
115 ================================================== ========= ========
116
117
118 ================================================== ========= ========
119 Convert file Time [ms] RAM [MB]
120 ================================================== ========= ========
121 asammdf 8.8.0 v3 to v4 1957 442
122 asammdf 8.8.0 v4 to v410 1981 438
123 asammdf 8.8.0 v4 to v420 2029 438
124 ================================================== ========= ========
125
126
127 ================================================== ========= ========
128 Merge 3 files Time [ms] RAM [MB]
129 ================================================== ========= ========
130 asammdf 8.8.0 v3 5020 648
131 mdfreader 4.2 v3 20639 1140
132 mdfreader 4.2 nodata v3 0* 0*
133 mdfreader 4.2 compress v3 19284 1135
134 asammdf 8.8.0 v4 6535 675
135 mdfreader 4.2 v4 27437 1170
136 mdfreader 4.2 nodata v4 28783 1246
137 mdfreader 4.2 compress v4 25897 1165
138 ================================================== ========= ========
139
140
141
142 Graphical results
143 -----------------
144
145 .. plot::
146
147 import matplotlib.pyplot as plt
148 import numpy as np
149
150 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
151 topic = 'Open'
152 aspect = 'time'
153 for_doc = True
154
155 with open(res, 'r') as f:
156 lines = f.readlines()
157
158 platform = 'x86' if '32 bit' in lines[2] else 'x64'
159
160 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
161
162 table_spans = {'open': [idx[1] + 1, idx[2]],
163 'save': [idx[4] + 1, idx[5]],
164 'get': [idx[7] + 1, idx[8]],
165 'mdf' : [idx[10] + 1, idx[11]],
166 'merge' : [idx[13] + 1, idx[14]]}
167
168
169 start, stop = table_spans[topic.lower()]
170
171 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
172 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
173 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
174
175
176 arr = ram if aspect == 'ram' else time
177
178
179 y_pos = list(range(len(cat)))
180
181 fig, ax = plt.subplots()
182 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
183
184 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
185 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
186
187 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
188 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
189 ax.set_yticks(y_pos)
190 ax.set_yticklabels(cat)
191 ax.invert_yaxis() # labels read top-to-bottom
192 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
193 if topic == 'Get':
194 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
195 else:
196 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
197 ax.xaxis.grid()
198
199 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
200
201 if aspect == 'time':
202 if topic == 'Get':
203 name = '{}_get_all_channels.png'.format(platform)
204 else:
205 name = '{}_{}.png'.format(platform, topic.lower())
206 else:
207 if topic == 'Get':
208 name = '{}_get_all_channels_ram_usage.png'.format(platform)
209 else:
210 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
211
212 plt.show()
213
214
215 .. plot::
216
217 import matplotlib.pyplot as plt
218 import numpy as np
219
220 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
221 topic = 'Open'
222 aspect = 'ram'
223 for_doc = True
224
225 with open(res, 'r') as f:
226 lines = f.readlines()
227
228 platform = 'x86' if '32 bit' in lines[2] else 'x64'
229
230 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
231
232 table_spans = {'open': [idx[1] + 1, idx[2]],
233 'save': [idx[4] + 1, idx[5]],
234 'get': [idx[7] + 1, idx[8]],
235 'convert' : [idx[10] + 1, idx[11]],
236 'merge' : [idx[13] + 1, idx[14]]}
237
238
239 start, stop = table_spans[topic.lower()]
240
241 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
242 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
243 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
244
245 if aspect == 'ram':
246 arr = ram
247 else:
248 arr = time
249
250 y_pos = list(range(len(cat)))
251
252 fig, ax = plt.subplots()
253 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
254
255 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
256 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
257
258 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
259 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
260 ax.set_yticks(y_pos)
261 ax.set_yticklabels(cat)
262 ax.invert_yaxis() # labels read top-to-bottom
263 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
264 if topic == 'Get':
265 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
266 else:
267 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
268 ax.xaxis.grid()
269
270 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
271
272 if aspect == 'time':
273 if topic == 'Get':
274 name = '{}_get_all_channels.png'.format(platform)
275 else:
276 name = '{}_{}.png'.format(platform, topic.lower())
277 else:
278 if topic == 'Get':
279 name = '{}_get_all_channels_ram_usage.png'.format(platform)
280 else:
281 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
282
283 plt.show()
284
285 .. plot::
286
287 import matplotlib.pyplot as plt
288 import numpy as np
289
290 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
291 topic = 'Save'
292 aspect = 'time'
293 for_doc = True
294
295 with open(res, 'r') as f:
296 lines = f.readlines()
297
298 platform = 'x86' if '32 bit' in lines[2] else 'x64'
299
300 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
301
302 table_spans = {'open': [idx[1] + 1, idx[2]],
303 'save': [idx[4] + 1, idx[5]],
304 'get': [idx[7] + 1, idx[8]],
305 'convert' : [idx[10] + 1, idx[11]],
306 'merge' : [idx[13] + 1, idx[14]]}
307
308
309 start, stop = table_spans[topic.lower()]
310
311 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
312 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
313 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
314
315 if aspect == 'ram':
316 arr = ram
317 else:
318 arr = time
319
320 y_pos = list(range(len(cat)))
321
322 fig, ax = plt.subplots()
323 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
324
325 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
326 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
327
328 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
329 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
330 ax.set_yticks(y_pos)
331 ax.set_yticklabels(cat)
332 ax.invert_yaxis() # labels read top-to-bottom
333 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
334 if topic == 'Get':
335 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
336 else:
337 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
338 ax.xaxis.grid()
339
340 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
341
342 if aspect == 'time':
343 if topic == 'Get':
344 name = '{}_get_all_channels.png'.format(platform)
345 else:
346 name = '{}_{}.png'.format(platform, topic.lower())
347 else:
348 if topic == 'Get':
349 name = '{}_get_all_channels_ram_usage.png'.format(platform)
350 else:
351 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
352
353 plt.show()
354
355
356 .. plot::
357
358 import matplotlib.pyplot as plt
359 import numpy as np
360
361 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
362 topic = 'Save'
363 aspect = 'ram'
364 for_doc = True
365
366 with open(res, 'r') as f:
367 lines = f.readlines()
368
369 platform = 'x86' if '32 bit' in lines[2] else 'x64'
370
371 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
372
373 table_spans = {'open': [idx[1] + 1, idx[2]],
374 'save': [idx[4] + 1, idx[5]],
375 'get': [idx[7] + 1, idx[8]],
376 'convert' : [idx[10] + 1, idx[11]],
377 'merge' : [idx[13] + 1, idx[14]]}
378
379
380 start, stop = table_spans[topic.lower()]
381
382 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
383 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
384 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
385
386 if aspect == 'ram':
387 arr = ram
388 else:
389 arr = time
390
391 y_pos = list(range(len(cat)))
392
393 fig, ax = plt.subplots()
394 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
395
396 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
397 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
398
399 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
400 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
401 ax.set_yticks(y_pos)
402 ax.set_yticklabels(cat)
403 ax.invert_yaxis() # labels read top-to-bottom
404 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
405 if topic == 'Get':
406 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
407 else:
408 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
409 ax.xaxis.grid()
410
411 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
412
413 if aspect == 'time':
414 if topic == 'Get':
415 name = '{}_get_all_channels.png'.format(platform)
416 else:
417 name = '{}_{}.png'.format(platform, topic.lower())
418 else:
419 if topic == 'Get':
420 name = '{}_get_all_channels_ram_usage.png'.format(platform)
421 else:
422 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
423
424 plt.show()
425
426 .. plot::
427
428 import matplotlib.pyplot as plt
429 import numpy as np
430
431 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
432 topic = 'Get'
433 aspect = 'time'
434 for_doc = True
435
436 with open(res, 'r') as f:
437 lines = f.readlines()
438
439 platform = 'x86' if '32 bit' in lines[2] else 'x64'
440
441 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
442
443 table_spans = {'open': [idx[1] + 1, idx[2]],
444 'save': [idx[4] + 1, idx[5]],
445 'get': [idx[7] + 1, idx[8]],
446 'convert' : [idx[10] + 1, idx[11]],
447 'merge' : [idx[13] + 1, idx[14]]}
448
449
450 start, stop = table_spans[topic.lower()]
451
452 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
453 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
454 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
455
456 if aspect == 'ram':
457 arr = ram
458 else:
459 arr = time
460
461 y_pos = list(range(len(cat)))
462
463 fig, ax = plt.subplots()
464 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
465
466 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
467 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
468
469 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
470 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
471 ax.set_yticks(y_pos)
472 ax.set_yticklabels(cat)
473 ax.invert_yaxis() # labels read top-to-bottom
474 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
475 if topic == 'Get':
476 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
477 else:
478 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
479 ax.xaxis.grid()
480
481 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
482
483 if aspect == 'time':
484 if topic == 'Get':
485 name = '{}_get_all_channels.png'.format(platform)
486 else:
487 name = '{}_{}.png'.format(platform, topic.lower())
488 else:
489 if topic == 'Get':
490 name = '{}_get_all_channels_ram_usage.png'.format(platform)
491 else:
492 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
493
494 plt.show()
495
496
497 .. plot::
498
499 import matplotlib.pyplot as plt
500 import numpy as np
501
502 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
503 topic = 'Get'
504 aspect = 'ram'
505 for_doc = True
506
507 with open(res, 'r') as f:
508 lines = f.readlines()
509
510 platform = 'x86' if '32 bit' in lines[2] else 'x64'
511
512 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
513
514 table_spans = {'open': [idx[1] + 1, idx[2]],
515 'save': [idx[4] + 1, idx[5]],
516 'get': [idx[7] + 1, idx[8]],
517 'convert' : [idx[10] + 1, idx[11]],
518 'merge' : [idx[13] + 1, idx[14]]}
519
520
521 start, stop = table_spans[topic.lower()]
522
523 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
524 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
525 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
526
527 if aspect == 'ram':
528 arr = ram
529 else:
530 arr = time
531
532 y_pos = list(range(len(cat)))
533
534 fig, ax = plt.subplots()
535 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
536
537 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
538 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
539
540 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
541 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
542 ax.set_yticks(y_pos)
543 ax.set_yticklabels(cat)
544 ax.invert_yaxis() # labels read top-to-bottom
545 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
546 if topic == 'Get':
547 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
548 else:
549 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
550 ax.xaxis.grid()
551
552 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
553
554 if aspect == 'time':
555 if topic == 'Get':
556 name = '{}_get_all_channels.png'.format(platform)
557 else:
558 name = '{}_{}.png'.format(platform, topic.lower())
559 else:
560 if topic == 'Get':
561 name = '{}_get_all_channels_ram_usage.png'.format(platform)
562 else:
563 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
564
565 plt.show()
566
567
568 .. plot::
569
570 import matplotlib.pyplot as plt
571 import numpy as np
572
573 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
574 topic = 'Convert'
575 aspect = 'time'
576 for_doc = True
577
578 with open(res, 'r') as f:
579 lines = f.readlines()
580
581 platform = 'x86' if '32 bit' in lines[2] else 'x64'
582
583 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
584
585 table_spans = {'open': [idx[1] + 1, idx[2]],
586 'save': [idx[4] + 1, idx[5]],
587 'get': [idx[7] + 1, idx[8]],
588 'convert' : [idx[10] + 1, idx[11]],
589 'merge' : [idx[13] + 1, idx[14]]}
590
591
592 start, stop = table_spans[topic.lower()]
593
594 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
595 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
596 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
597
598 if aspect == 'ram':
599 arr = ram
600 else:
601 arr = time
602
603 y_pos = list(range(len(cat)))
604
605 fig, ax = plt.subplots()
606 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
607
608 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
609 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
610
611 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
612 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
613 ax.set_yticks(y_pos)
614 ax.set_yticklabels(cat)
615 ax.invert_yaxis() # labels read top-to-bottom
616 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
617 if topic == 'Get':
618 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
619 else:
620 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
621 ax.xaxis.grid()
622
623 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
624
625 if aspect == 'time':
626 if topic == 'Get':
627 name = '{}_get_all_channels.png'.format(platform)
628 else:
629 name = '{}_{}.png'.format(platform, topic.lower())
630 else:
631 if topic == 'Get':
632 name = '{}_get_all_channels_ram_usage.png'.format(platform)
633 else:
634 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
635
636 plt.show()
637
638
639 .. plot::
640
641 import matplotlib.pyplot as plt
642 import numpy as np
643
644 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
645 topic = 'Convert'
646 aspect = 'ram'
647 for_doc = True
648
649 with open(res, 'r') as f:
650 lines = f.readlines()
651
652 platform = 'x86' if '32 bit' in lines[2] else 'x64'
653
654 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
655
656 table_spans = {'open': [idx[1] + 1, idx[2]],
657 'save': [idx[4] + 1, idx[5]],
658 'get': [idx[7] + 1, idx[8]],
659 'convert' : [idx[10] + 1, idx[11]],
660 'merge' : [idx[13] + 1, idx[14]]}
661
662
663 start, stop = table_spans[topic.lower()]
664
665 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
666 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
667 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
668
669 if aspect == 'ram':
670 arr = ram
671 else:
672 arr = time
673
674 y_pos = list(range(len(cat)))
675
676 fig, ax = plt.subplots()
677 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
678
679 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
680 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
681
682 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
683 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
684 ax.set_yticks(y_pos)
685 ax.set_yticklabels(cat)
686 ax.invert_yaxis() # labels read top-to-bottom
687 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
688 if topic == 'Get':
689 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
690 else:
691 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
692 ax.xaxis.grid()
693
694 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
695
696 if aspect == 'time':
697 if topic == 'Get':
698 name = '{}_get_all_channels.png'.format(platform)
699 else:
700 name = '{}_{}.png'.format(platform, topic.lower())
701 else:
702 if topic == 'Get':
703 name = '{}_get_all_channels_ram_usage.png'.format(platform)
704 else:
705 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
706
707 plt.show()
708
709
710 .. plot::
711
712 import matplotlib.pyplot as plt
713 import numpy as np
714
715 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
716 topic = 'Merge'
717 aspect = 'time'
718 for_doc = True
719
720 with open(res, 'r') as f:
721 lines = f.readlines()
722
723 platform = 'x86' if '32 bit' in lines[2] else 'x64'
724
725 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
726
727 table_spans = {'open': [idx[1] + 1, idx[2]],
728 'save': [idx[4] + 1, idx[5]],
729 'get': [idx[7] + 1, idx[8]],
730 'convert' : [idx[10] + 1, idx[11]],
731 'merge' : [idx[13] + 1, idx[14]]}
732
733
734 start, stop = table_spans[topic.lower()]
735
736 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
737 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
738 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
739
740 if aspect == 'ram':
741 arr = ram
742 else:
743 arr = time
744
745 y_pos = list(range(len(cat)))
746
747 fig, ax = plt.subplots()
748 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
749
750 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
751 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
752
753 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
754 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
755 ax.set_yticks(y_pos)
756 ax.set_yticklabels(cat)
757 ax.invert_yaxis() # labels read top-to-bottom
758 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
759 if topic == 'Get':
760 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
761 else:
762 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
763 ax.xaxis.grid()
764
765 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
766
767 if aspect == 'time':
768 if topic == 'Get':
769 name = '{}_get_all_channels.png'.format(platform)
770 else:
771 name = '{}_{}.png'.format(platform, topic.lower())
772 else:
773 if topic == 'Get':
774 name = '{}_get_all_channels_ram_usage.png'.format(platform)
775 else:
776 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
777
778 plt.show()
779
780
781 .. plot::
782
783 import matplotlib.pyplot as plt
784 import numpy as np
785
786 res = '../benchmarks/results/x64_asammdf_8.8.0_mdfreader_4.2.rst'
787 topic = 'Merge'
788 aspect = 'ram'
789 for_doc = True
790
791 with open(res, 'r') as f:
792 lines = f.readlines()
793
794 platform = 'x86' if '32 bit' in lines[2] else 'x64'
795
796 idx = [i for i, line in enumerate(lines) if line.startswith('==')]
797
798 table_spans = {'open': [idx[1] + 1, idx[2]],
799 'save': [idx[4] + 1, idx[5]],
800 'get': [idx[7] + 1, idx[8]],
801 'convert' : [idx[10] + 1, idx[11]],
802 'merge' : [idx[13] + 1, idx[14]]}
803
804
805 start, stop = table_spans[topic.lower()]
806
807 cat = [l[:50].strip(' \t\n\r\0*') for l in lines[start: stop]]
808 time = np.array([int(l[50:61].strip(' \t\n\r\0*')) for l in lines[start: stop]])
809 ram = np.array([int(l[61:].strip(' \t\n\r\0*')) for l in lines[start: stop]])
810
811 if aspect == 'ram':
812 arr = ram
813 else:
814 arr = time
815
816 y_pos = list(range(len(cat)))
817
818 fig, ax = plt.subplots()
819 fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)
820
821 asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')]
822 mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]
823
824 ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green')
825 ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black')
826 ax.set_yticks(y_pos)
827 ax.set_yticklabels(cat)
828 ax.invert_yaxis() # labels read top-to-bottom
829 ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]')
830 if topic == 'Get':
831 ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage'))
832 else:
833 ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage'))
834 ax.xaxis.grid()
835
836 fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)
837
838 if aspect == 'time':
839 if topic == 'Get':
840 name = '{}_get_all_channels.png'.format(platform)
841 else:
842 name = '{}_{}.png'.format(platform, topic.lower())
843 else:
844 if topic == 'Get':
845 name = '{}_get_all_channels_ram_usage.png'.format(platform)
846 else:
847 name = '{}_{}_ram_usage.png'.format(platform, topic.lower())
848
849 plt.show()
850