Skip to content

Latest commit

 

History

History
871 lines (647 loc) · 30.6 KB

benchmarks.rst

File metadata and controls

871 lines (647 loc) · 30.6 KB
.red {color:red} .blue {color:blue} .green {color:green} .cyan {color:cyan} .magenta {color:magenta} .orange {color:orange} .brown {color:brown}

Benchmarks

asammdf relies heavily on dict objects. Starting with Python 3.6 the dict objects are more compact and ordered (implementation detail); asammdf uses takes advantage of those changes so for best performance it is advised to use Python >= 3.6.

Test setup

The benchmarks were done using two test files (available here #14) (for mdf version 3 and 4) of around 170MB. The files contain 183 data groups and a total of 36424 channels.

asamdf 3.0.0 was compared against mdfreader 2.7.5. mdfreader seems to be the most used Python package to handle MDF files, and it also supports both version 3 and 4 of the standard.

The three benchmark cathegories are file open, file save and extracting the data for all channels inside the file(36424 calls). For each cathegory two aspect were noted: elapsed time and peak RAM usage.

Dependencies

You will need the following packages to be able to run the benchmark script

  • psutil
  • mdfreader

Usage

Extract the test files from the archive, or provide a folder that contains the files "test.mdf" and "test.mf4". Run the module bench.py ( see --help option for available options )

x64 Python results

Benchmark environment

  • 3.6.4 (default, Jan 5 2018, 02:35:40) [GCC 7.2.1 20171224]
  • Linux-4.15.0-1-MANJARO-x86_64-with-arch-Manjaro-Linux
  • 4GB installed RAM

Notations used in the results

  • full = asammdf MDF object created with memory=full (everything loaded into RAM)
  • low = asammdf MDF object created with memory=low (raw channel data not loaded into RAM, but metadata loaded to RAM)
  • minimum = asammdf MDF object created with memory=full (lowest possible RAM usage)
  • compress = mdfreader mdf object created with compression=blosc
  • noDataLoading = mdfreader mdf object read with noDataLoading=True

Files used for benchmark:

  • 183 groups
  • 36424 channels

Raw data

Open file Time [ms] RAM [MB]
asammdf 3.0.0 full mdfv3

706

256

asammdf 3.0.0 low mdfv3

637

103

asammdf 3.0.0 minimum mdfv3

612

64

mdfreader 2.7.5 mdfv3

2201

414

mdfreader 2.7.5 compress mdfv3

1871

281

mdfreader 2.7.5 noDataLoading mdfv3

948

160

asammdf 3.0.0 full mdfv4

2599

296

asammdf 3.0.0 low mdfv4

2485

131

asammdf 3.0.0 minimum mdfv4

1376

64

mdfreader 2.7.5 mdfv4

5706

435

mdfreader 2.7.5 compress mdfv4

5453

303

mdfreader 2.7.5 noDataLoading mdfv4

3904

181

Save file Time [ms] RAM [MB]
asammdf 3.0.0 full mdfv3

468

258

asammdf 3.0.0 low mdfv3

363

110

asammdf 3.0.0 minimum mdfv3

919

80

mdfreader 2.7.5 mdfv3

6424

451

mdfreader 2.7.5 noDataLoading mdfv3

7364

510

mdfreader 2.7.5 compress mdfv3

6624

449

asammdf 3.0.0 full mdfv4

984

319

asammdf 3.0.0 low mdfv4

1028

156

asammdf 3.0.0 minimum mdfv4

2786

80

mdfreader 2.7.5 mdfv4

3355

460

mdfreader 2.7.5 noDataLoading mdfv4

5153

483

mdfreader 2.7.5 compress mdfv4

3773

457

Get all channels (36424 calls) Time [ms] RAM [MB]
asammdf 3.0.0 full mdfv3

1196

269

asammdf 3.0.0 low mdfv3

5230

121

asammdf 3.0.0 minimum mdfv3

6871

85

mdfreader 2.7.5 mdfv3

77

414

mdfreader 2.7.5 noDataLoading mdfv3

13036

195

mdfreader 2.7.5 compress mdfv3

184

281

asammdf 3.0.0 full mdfv4

1207

305

asammdf 3.0.0 low mdfv4

5613

144

asammdf 3.0.0 minimum mdfv4

7725

80

mdfreader 2.7.5 mdfv4

74

435

mdfreader 2.7.5 noDataLoading mdfv4

14140

207

mdfreader 2.7.5 compress mdfv4

171

307

Convert file Time [ms] RAM [MB]
asammdf 3.0.0 full v3 to v4

3712

565

asammdf 3.0.0 low v3 to v4

4091

228

asammdf 3.0.0 minimum v3 to v4

6740

126

asammdf 3.0.0 full v4 to v3

3787

571

asammdf 3.0.0 low v4 to v3

4546

222

asammdf 3.0.0 minimum v4 to v3

8369

115

Merge files Time [ms] RAM [MB]
asammdf 3.0.0 full v3

7297

975

asammdf 3.0.0 low v3

7766

282

asammdf 3.0.0 minimum v3

11363

163

mdfreader 2.7.5 mdfv3

13039

1301

mdfreader 2.7.5 compress mdfv3

12877

1298

mdfreader 2.7.5 noDataLoading mdfv3

12981

1421

asammdf 3.0.0 full v4

11313

1025

asammdf 3.0.0 low v4

12155

322

asammdf 3.0.0 minimum v4

18787

152

mdfreader 2.7.5 mdfv4

21423

1309

mdfreader 2.7.5 noDataLoading mdfv4

20142

1352

mdfreader 2.7.5 compress mdfv4

20600

1309

Graphical results

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Open' aspect = 'time' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

arr = ram if aspect == 'ram' else time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Open' aspect = 'ram' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Save' aspect = 'time' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Save' aspect = 'ram' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Get' aspect = 'time' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Get' aspect = 'ram' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Convert' aspect = 'time' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Convert' aspect = 'ram' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Merge' aspect = 'time' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()

import matplotlib.pyplot as plt import numpy as np

res = '../benchmarks/results/x64_asammdf_3.0.0_mdfreader_2.7.5.txt' topic = 'Merge' aspect = 'ram' for_doc = True

with open(res, 'r') as f:

lines = f.readlines()

platform = 'x86' if '32 bit' in lines[2] else 'x64'

idx = [i for i, line in enumerate(lines) if line.startswith('==')]

table_spans = {'open': [idx[1] + 1, idx[2]],

'save': [idx[4] + 1, idx[5]], 'get': [idx[7] + 1, idx[8]], 'convert' : [idx[10] + 1, idx[11]], 'merge' : [idx[13] + 1, idx[14]]}

start, stop = table_spans[topic.lower()]

cat = [l[:50].strip(' tnr0') for l in lines[start: stop]] time = np.array([int(l[50:61].strip(' tnr0')) for l in lines[start: stop]]) ram = np.array([int(l[61:].strip(' tnr0*')) for l in lines[start: stop]])

if aspect == 'ram':

arr = ram

else:

arr = time

y_pos = list(range(len(cat)))

fig, ax = plt.subplots() fig.set_size_inches(15, 3.8 / 12 * len(cat) + 1.2)

asam_pos = [i for i, c in enumerate(cat) if c.startswith('asam')] mdfreader_pos = [i for i, c in enumerate(cat) if c.startswith('mdfreader')]

ax.barh(asam_pos, arr[asam_pos], color='green', ecolor='green') ax.barh(mdfreader_pos, arr[mdfreader_pos], color='blue', ecolor='black') ax.set_yticks(y_pos) ax.set_yticklabels(cat) ax.invert_yaxis() # labels read top-to-bottom ax.set_xlabel('Time [ms]' if aspect == 'time' else 'RAM [MB]') if topic == 'Get': ax.set_title('Get all channels (36424 calls) - {}'.format('time' if aspect == 'time' else 'ram usage')) else: ax.set_title('{} test file - {}'.format(topic, 'time' if aspect == 'time' else 'ram usage')) ax.xaxis.grid()

fig.subplots_adjust(bottom=0.72/fig.get_figheight(), top=1-0.48/fig.get_figheight(), left=0.4, right=0.9)

if aspect == 'time':
if topic == 'Get':

name = '{}_get_all_channels.png'.format(platform)

else:

name = '{}_{}.png'.format(platform, topic.lower())

else:
if topic == 'Get':

name = '{}_get_all_channels_ram_usage.png'.format(platform)

else:

name = '{}_{}_ram_usage.png'.format(platform, topic.lower())

plt.show()