Skip to content

.statistics()

Jacob Morris edited this page Jun 19, 2019 · 3 revisions

.statistics()

Timer.statistics() provides a way to get basic statistics on the runs within a given split. Currently, the number of runs, total time of all the runs, min and max times, average time, standard deviation, and variance are all displayed for each split. By default, all splits are displayed. However, the statistics for a specific split can be displayed by setting split_index to the index or label of a split.

timer = Timer()
timer.time_it(sorted, [randint(0, 100000) for _ in range(randint(0, 10000))], log_arguments=True, runs=5)

timer.output(transformers=len)
# sorted:
#        0.08724 ms - sorted(565)                                [runs=  1, iterations=  1]                     
#        0.07745 ms - sorted(565)                                [runs=  1, iterations=  1]                     
#        0.05925 ms - sorted(565)                                [runs=  1, iterations=  1]                     
#        0.06065 ms - sorted(565)                                [runs=  1, iterations=  1]                     
#        0.05458 ms - sorted(565)                                [runs=  1, iterations=  1]     

timer.statistics()
# sorted[runs=5, total=0.33917 ms]:
#      Min | Max | Average = 0.05458 | 0.08724 | 0.06783 ms
#       Standard Deviation = 0.01241 ms
#                 Variance = 0.0 ms