-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP1.hs
90 lines (84 loc) · 6.9 KB
/
P1.hs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module Main (main) where
import Criterion.Main
import System.Random
import AritmeticaModular
shanks_list :: (Integral a, Random a) => (a, a, a) -> a
shanks_list (a,c,p) = baby_s_giant_s a c p
cuadrados_list :: (Integral a, Random a) => (a,a) -> (a,a)
cuadrados_list (a,p) = cuadrados a p
raices_list :: (Integral a, Random a) => (a,a,a) -> (a,a,a,a)
raices_list (r,p,q) = raices_cuadradas r p q
rho_f :: (Integral a, Random a) => a -> (a,a)
rho_f n = rho n func
-- Our benchmark harness.
main = defaultMain [
bgroup "miller_rabin" [ bench "46381" $ whnf miller_rabin (46381 :: Integer)
, bench "768479" $ whnf miller_rabin (768479 :: Integer)
, bench "9476407" $ whnf miller_rabin (9476407 :: Integer)
, bench "36780481" $ whnf miller_rabin (36780481 :: Integer)
, bench "562390847" $ whnf miller_rabin (562390847 :: Integer)
, bench "1894083629" $ whnf miller_rabin (1894083629 :: Integer)
, bench "65398261921" $ whnf miller_rabin (65398261921 :: Integer)
, bench "364879542899" $ whnf miller_rabin (364879542899 :: Integer)
, bench "8590365927553" $ whnf miller_rabin (8590365927553 :: Integer)
, bench "28564333765949" $ whnf miller_rabin (28564333765949 :: Integer)
, bench "123456789101119" $ whnf miller_rabin (123456789101119 :: Integer)
],
bgroup "shanks" [ bench "46381" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (46381 :: Integer))
, bench "768479" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (768479 :: Integer))
, bench "9476407" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (9476407 :: Integer))
, bench "36780481" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (36780481 :: Integer))
, bench "562390847" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (562390847 :: Integer))
, bench "1894083629" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (1894083629 :: Integer))
, bench "65398261921" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (65398261921 :: Integer))
, bench "364879542899" $ whnf shanks_list ((123456 :: Integer), (1749924 :: Integer), (364879542899 :: Integer))
],
bgroup "cuadrados" [ bench "46381" $ whnf cuadrados_list ((123456 :: Integer), (46381 :: Integer))
, bench "768479" $ whnf cuadrados_list ((123457 :: Integer), (768479 :: Integer))
, bench "9476407" $ whnf cuadrados_list ((123456 :: Integer), (9476407 :: Integer))
, bench "36780481" $ whnf cuadrados_list ((123456 :: Integer), (36780481 :: Integer))
, bench "562390847" $ whnf cuadrados_list ((123456 :: Integer), (562390847 :: Integer))
, bench "1894083629" $ whnf cuadrados_list ((123456 :: Integer), (1894083629 :: Integer))
, bench "65398261921" $ whnf cuadrados_list ((123457 :: Integer), (65398261921 :: Integer))
, bench "364879542899" $ whnf cuadrados_list ((123457 :: Integer), (364879542899 :: Integer))
, bench "8590365927553" $ whnf cuadrados_list ((123456 :: Integer), (8590365927553 :: Integer))
, bench "28564333765949" $ whnf cuadrados_list ((123460 :: Integer), (28564333765949 :: Integer))
, bench "123456789101119" $ whnf cuadrados_list ((123458 :: Integer), (123456789101119 :: Integer))
],
bgroup "raices" [ bench "46381" $ whnf raices_list ((123456 :: Integer), (46381 :: Integer), (46381 :: Integer))
, bench "768479" $ whnf raices_list ((123457 :: Integer), (46381 :: Integer), (768479 :: Integer))
, bench "9476407" $ whnf raices_list ((123456 :: Integer), (46381 :: Integer), (9476407 :: Integer))
, bench "36780481" $ whnf raices_list ((123456 :: Integer), (46381 :: Integer), (36780481 :: Integer))
, bench "562390847" $ whnf raices_list ((123456 :: Integer), (46381 :: Integer), (562390847 :: Integer))
, bench "1894083629" $ whnf raices_list ((123456 :: Integer), (46381 :: Integer), (1894083629 :: Integer))
, bench "65398261921" $ whnf raices_list ((123457 :: Integer), (46381 :: Integer), (65398261921 :: Integer))
, bench "364879542899" $ whnf raices_list ((123457 :: Integer), (46381 :: Integer), (364879542899 :: Integer))
, bench "8590365927553" $ whnf raices_list ((123456 :: Integer), (46381 :: Integer), (8590365927553 :: Integer))
, bench "28564333765949" $ whnf raices_list ((123460 :: Integer), (46381 :: Integer), (28564333765949 :: Integer))
, bench "123456789101119" $ whnf raices_list ((123458 :: Integer), (46381 :: Integer), (123456789101119 :: Integer))
],
bgroup "metodo_fermat" [ bench "46382" $ whnf metodo_fermat (46382 :: Integer)
, bench "7684781" $ whnf metodo_fermat (7684781 :: Integer)
, bench "9476408" $ whnf metodo_fermat (9476408 :: Integer)
, bench "36780482" $ whnf metodo_fermat (36780482 :: Integer)
, bench "562390848" $ whnf metodo_fermat (562390848 :: Integer)
, bench "1894083630" $ whnf metodo_fermat (1894083630 :: Integer)
, bench "65398261923" $ whnf metodo_fermat (65398261923 :: Integer)
, bench "364879542897" $ whnf metodo_fermat (364879542897 :: Integer)
, bench "8590365927554" $ whnf metodo_fermat (8590365927554 :: Integer)
, bench "28564333765948" $ whnf metodo_fermat (28564333765948 :: Integer)
, bench "123456789101121" $ whnf metodo_fermat (123456789101121 :: Integer)
],
bgroup "rho" [ bench "46382" $ whnf rho_f (46382 :: Integer)
, bench "768481" $ whnf rho_f (768481 :: Integer)
, bench "9476408" $ whnf rho_f (9476408 :: Integer)
, bench "36780482" $ whnf rho_f (36780482 :: Integer)
, bench "562390848" $ whnf rho_f (562390848 :: Integer)
, bench "1894083630" $ whnf rho_f (1894083630 :: Integer)
, bench "65398261923" $ whnf rho_f (65398261923 :: Integer)
, bench "364879542897" $ whnf rho_f (364879542897 :: Integer)
, bench "8590365927554" $ whnf rho_f (8590365927554 :: Integer)
, bench "28564333765948" $ whnf rho_f (28564333765948 :: Integer)
, bench "123456789101121" $ whnf rho_f (123456789101121 :: Integer)
]
]