MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / benchmark_a_function

Function benchmark_a_function

maths/number_of_digits.py:98–101  ·  view source on GitHub ↗
(func: Callable, value: int)

Source from the content-addressed store, hash-verified

96 from collections.abc import Callable
97
98 def benchmark_a_function(func: Callable, value: int) -> None:
99 call = f"{func.__name__}({value})"
100 timing = timeit(f"__main__.{call}", setup="import __main__")
101 print(f"{call}: {func(value)} -- {timing} seconds")
102
103 for value in (262144, 1125899906842624, 1267650600228229401496703205376):
104 for func in (num_digits, num_digits_fast, num_digits_faster):

Callers 1

benchmarkFunction · 0.70

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected