module utils.benchmark#

Short summary#

module onnxcustom.utils.benchmark

Tools to help benchmarking.

source on GitHub

Functions#

function

truncated documentation

measure_time

Measures a statement and returns the results as a dictionary.

Documentation#

Tools to help benchmarking.

source on GitHub

onnxcustom.utils.benchmark.measure_time(stmt, context, repeat=10, number=50, div_by_number=False)#

Measures a statement and returns the results as a dictionary.

Parameters:
  • stmt – string

  • context – variable to know in a dictionary

  • repeat – average over repeat experiment

  • number – number of executions in one row

  • div_by_number – divide by the number of executions

Returns:

dictionary

Measure the processing time of a function

<<<

from onnxcustom.utils import measure_time
from math import cos

res = measure_time("cos(x)", context=dict(cos=cos, x=5.))
print(res)

>>>

    {'average': 2.3502600379288195e-05, 'deviation': 1.4356518673239557e-06, 'min_exec': 2.2359017748385668e-05, 'max_exec': 2.750899875536561e-05, 'repeat': 10, 'number': 50}

See Timer.repeat for a better understanding of parameter repeat and number. The function returns a duration corresponding to number times the execution of the main statement.

source on GitHub