module tools.speed_measure

Short summary

module mlprodict.tools.speed_measure

Measures speed.

source on GitHub

Functions

function

truncated documentation

measure_time

Measures a statement and returns the results as a dictionary.

Documentation

Measures speed.

source on GitHub

mlprodict.tools.speed_measure.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

<<<

from mlprodict.tools import measure_time
from math import cos

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

>>>

    {'average': 1.2981891632080079e-05, 'deviation': 1.01344747546742e-06, 'min_exec': 1.2439675629138947e-05, 'max_exec': 1.597963273525238e-05, 'repeat': 10, 'number': 50, 'context_size': 232}

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