
Measures a statement and returns the results as a dictionary.
stmt – string
context – variable to know in a dictionary
repeat – average overrepeat experiment
number – number of executions in one row
div_by_number – divide by the number of executions
max_time – execute the statement until the total goesbeyond this time (approximatively),repeat is ignored,div_by_number must be set to True
dictionary
<<<
fromonnx_array_api.ext_test_caseimportmeasure_timefrommathimportcosres=measure_time(lambda:cos(0.5))print(res)
>>>
{'average':8.540000271750614e-08,'deviation':1.2932129190009065e-08,'min_exec':7.999995432328433e-08,'max_exec':1.2399999832268805e-07,'repeat':10,'number':50,'ttime':8.540000271750615e-07,'context_size':64}
SeeTimer.repeatfor a better understanding of parameterrepeat andnumber.The function returns a duration corresponding tonumber times the execution of the main statement.
Changed in version 0.4:Parametermax_time was added.
Catches warnings.
warns – warnings to ignore
Runs a function and capture standard output and error.
fct – function to run
result offct, output, error