diff --git a/src/benchmarking/and_vs_mod.py b/src/benchmarking/and_vs_mod.py index e988d10..7b0d7eb 100644 --- a/src/benchmarking/and_vs_mod.py +++ b/src/benchmarking/and_vs_mod.py @@ -5,19 +5,21 @@ import random BENCHMARK_COUNT = 180 SUPERTESTS = 90 +MAX_SHIFT_VALUE = 18 +SHIFT_VALUE_DIVIDER = SUPERTESTS // MAX_SHIFT_VALUE op_and = lambda a, b: a & (b - 1) op_mod = lambda a, b: a % b timeit_macro = lambda func_name, number: timeit( - f"%s(random.randint(0, 2 ** 32 - 1), 1 << ({number} // 900))" % func_name, + f"%s(random.randint(0, 2 ** 32 - 1), 1 << ({number} // SHIFT_VALUE_DIVIDER))" % func_name, setup="from __main__ import %s\nimport random" % func_name, number=number, ) if __name__ == "__main__": print( - f"Testing performance of modulo and bitwise AND remainder methods for binary divisors from 1 to {1 << (BENCHMARK_COUNT * (SUPERTESTS - 1) // 900)}:" + f"Testing performance of modulo and bitwise AND remainder methods for binary divisors from 1 to {1 << (BENCHMARK_COUNT * (SUPERTESTS - 1) // SHIFT_VALUE_DIVIDER)}:" ) time1_total = 0