-
Notifications
You must be signed in to change notification settings - Fork 0
/
modular_exp_bench.py
executable file
·39 lines (31 loc) · 1.17 KB
/
modular_exp_bench.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import timeit
import bench, modular_exp
REPEAT_COUNT = 20
for power_digits in range(1, 7):
x = 7 ** 400
power = 10 ** power_digits
modulus = 11 ** 300
print("x 7^400, power 10^%d, modulus 11^300: " % \
(power_digits))
print('\n'.join(map(lambda x: "%s: time %f s, memory %f MB" % x, \
bench.bench([modular_exp.square_modular_exp, \
modular_exp.generic_modular_exp], \
[x, power, modulus], REPEAT_COUNT))))
for power_digits in [7]:
x = 7 ** 400
power = 10 ** power_digits
modulus = 11 ** 300
print("x 7^400, power 10^%d, modulus 11^300: " % \
(power_digits))
print('\n'.join(map(lambda x: "%s: time %f s, memory %f MB" % x, \
bench.bench([modular_pow.square_modular_pow], \
[x, power, modulus], REPEAT_COUNT))))
for power_digits in range(100, 1000, 100):
x = 7 ** 400
power = 10 ** power_digits
modulus = 11 ** 300
print("x 7^400, power 10^%d, modulus 11^300: " % \
(power_digits))
print('\n'.join(map(lambda x: "%s: time %f s, memory %f MB" % x, \
bench.bench([modular_exp.square_modular_exp], \
[x, power, modulus], REPEAT_COUNT))))