aboutsummaryrefslogtreecommitdiff
path: root/measurements
diff options
context:
space:
mode:
authorGravatar jadep <jade.philipoom@gmail.com>2017-11-12 23:24:57 -0500
committerGravatar jadep <jade.philipoom@gmail.com>2017-11-12 23:37:23 -0500
commitfe09bfcc7fab6148e9aed9fb570f74494dad9fb6 (patch)
tree60fd2e1195b2fc7e59665bf822a99a6a0e10883d /measurements
parentb671976eb2364b6d41cc3e450c2570558a0161ec (diff)
update to graph generation
Diffstat (limited to 'measurements')
-rw-r--r--measurements/2017-11-03/table.tex737
-rw-r--r--measurements/tolatex.py100
2 files changed, 420 insertions, 417 deletions
diff --git a/measurements/2017-11-03/table.tex b/measurements/2017-11-03/table.tex
index aaa673a6b..7d7541e59 100644
--- a/measurements/2017-11-03/table.tex
+++ b/measurements/2017-11-03/table.tex
@@ -1,405 +1,358 @@
- \begin{figure*}
- \begin{tikzpicture}
- \begin{axis}[
- height=11cm,
- width=\textwidth,
- grid=major,
- legend pos= north west,
- xlabel=Prime Size (bits),
- ylabel=Time (seconds)]
- \addplot[color=blue,mark=triangle*] coordinates {
- (127, 0.12)
- (129, 0.19)
- (137, 0.20)
- (140, 0.20)
- (141, 0.20)
- (150, 0.20)
- (152, 0.19)
- (158, 0.20)
- (171, 0.28)
- (174, 0.28)
- (189, 0.28)
- (190, 0.29)
- (191, 0.28)
- (192, 0.27)
- (205, 0.36)
- (206, 0.37)
- (212, 0.38)
- (213, 0.37)
- (216, 0.38)
- (221, 0.38)
- (222, 0.37)
- (224, 0.32)
+ \begin{figure*}
+ \begin{tikzpicture}
+ \begin{axis}[
+ height=9cm,
+ width=\textwidth,
+ legend pos= north west,
+ xtick distance=100,
+ extra x ticks={130,255,448,480},
+ extra x tick style={grid=major, tick label style={rotate=45,anchor=east}},
+ extra x tick labels={poly1305,curve25519/p256,goldilocks,ridinghood},
+ xlabel=log2(prime),
+ ylabel=Time (seconds)] \addplot[color=blue,mark=square*] coordinates {
+ (127.0, 0.04)
+ (129.0, 0.08)
+ (137.0, 0.09)
+ (140.0, 0.08)
+ (141.0, 0.08)
+ (150.0, 0.08)
+ (152.0, 0.09)
+ (158.0, 0.08)
+ (165.0, 0.08)
+ (166.0, 0.08)
+ (171.0, 0.08)
+ (174.0, 0.08)
+ (189.0, 0.08)
+ (190.0, 0.08)
+ (191.0, 0.08)
+ (192.0, 0.08)
+ (204.37503943134692, 0.13)
+ (206.0, 0.13)
+ (212.0, 0.13)
+ (213.0, 0.13)
+ (216.0, 0.12)
+ (221.0, 0.13)
+ (222.0, 0.13)
+ (224.0, 0.12)
+ (226.0, 0.12)
+ (230.0, 0.13)
+ (235.0, 0.13)
+ (243.0, 0.12)
+ (251.0, 0.13)
+ (253.98877343250717, 0.13)
+ (255.0, 0.13)
+ (256.0, 0.13)
+ (255.99999999966408, 0.11)
+ (255.9980614856364, 0.12)
+ (266.0, 0.18)
+ (285.0, 0.19)
+ (291.0, 0.19)
+ (321.0, 0.25)
+ (336.0, 0.25)
+ (338.0, 0.27)
+ (369.0, 0.27)
+ (379.0, 0.28)
+ (382.0, 0.27)
+ (383.0, 0.27)
+ (384.0, 0.26)
+ (383.9998899269044, 0.23)
+ (383.467605550083, 0.23)
+ (401.0, 0.35)
+ (414.0, 0.35)
+ (416.0, 0.35)
+ (444.0, 0.35)
+ (448.0, 0.32)
};
- \addlegendentry{fiat\_montgomery32}
-
- \addplot[color=blue,mark=square*] coordinates {
- (127, 0.04)
- (129, 0.08)
- (137, 0.09)
- (140, 0.08)
- (141, 0.08)
- (150, 0.08)
- (152, 0.09)
- (158, 0.08)
- (165, 0.08)
- (166, 0.08)
- (171, 0.08)
- (174, 0.08)
- (189, 0.08)
- (190, 0.08)
- (191, 0.08)
- (192, 0.08)
- (205, 0.13)
- (206, 0.13)
- (212, 0.13)
- (213, 0.13)
- (216, 0.12)
- (221, 0.13)
- (222, 0.13)
- (224, 0.12)
- (226, 0.12)
- (230, 0.13)
- (235, 0.13)
- (243, 0.12)
- (251, 0.13)
- (254, 0.13)
- (255, 0.13)
- (256, 0.13)
- (266, 0.18)
- (285, 0.19)
- (291, 0.19)
- (321, 0.25)
- (336, 0.25)
- (338, 0.27)
- (369, 0.27)
- (379, 0.28)
- (382, 0.27)
- (383, 0.27)
- (384, 0.26)
- (401, 0.35)
- (414, 0.35)
- (416, 0.35)
- (444, 0.35)
- (448, 0.32)
- };
- \addlegendentry{fiat\_montgomery64}
-
- \addplot[color=blue,mark=triangle] coordinates {
- (127, 0.05)
- (129, 0.06)
- (130, 0.03)
- (137, 0.11)
- (140, 0.06)
- (141, 0.06)
- (150, 0.06)
- (152, 0.06)
- (158, 0.06)
- (165, 0.11)
- (166, 0.16)
- (171, 0.12)
- (174, 0.12)
- (191, 0.15)
- (194, 0.09)
- (198, 0.11)
- (206, 0.19)
- (213, 0.28)
- (216, 0.08)
- (221, 0.13)
- (222, 0.13)
- (230, 0.13)
- (235, 0.10)
- (243, 0.10)
- (251, 0.13)
- (255, 0.13)
- (256, 0.18)
- (266, 0.19)
- (285, 0.27)
- (291, 0.18)
- (321, 0.30)
- (322, 0.21)
- (336, 0.23)
- (338, 0.20)
- (369, 0.29)
- (401, 0.30)
- (416, 0.25)
- };
- \addlegendentry{fiat\_solinas32}
+ \addlegendentry{ours, Montgomery reduction}
\addplot[color=blue,mark=square] coordinates {
- (127, 0.02)
- (129, 0.03)
- (130, 0.03)
- (137, 0.05)
- (140, 0.04)
- (141, 0.03)
- (150, 0.03)
- (152, 0.04)
- (158, 0.04)
- (165, 0.03)
- (166, 0.03)
- (171, 0.03)
- (174, 0.03)
- (189, 0.04)
- (190, 0.04)
- (191, 0.07)
- (192, 0.05)
- (194, 0.04)
- (196, 0.04)
- (198, 0.04)
- (206, 0.04)
- (212, 0.05)
- (213, 0.04)
- (216, 0.04)
- (221, 0.04)
- (222, 0.05)
- (226, 0.04)
- (230, 0.05)
- (235, 0.07)
- (243, 0.10)
- (251, 0.06)
- (255, 0.06)
- (256, 0.06)
- (266, 0.06)
- (285, 0.06)
- (291, 0.07)
- (321, 0.10)
- (336, 0.10)
- (338, 0.10)
- (369, 0.15)
- (379, 0.13)
- (382, 0.23)
- (384, 0.15)
- (401, 0.15)
- (414, 0.20)
- (416, 0.12)
- (444, 0.16)
- (448, 0.12)
- (450, 0.12)
- (452, 0.16)
- (468, 0.17)
- (480, 0.15)
- (488, 0.55)
- (489, 0.20)
- (495, 0.19)
- (511, 0.24)
- (512, 0.24)
- (521, 0.25)
+ (127.0, 0.02)
+ (129.0, 0.03)
+ (130.0, 0.03)
+ (137.0, 0.05)
+ (140.0, 0.04)
+ (141.0, 0.03)
+ (150.0, 0.03)
+ (152.0, 0.04)
+ (158.0, 0.04)
+ (165.0, 0.03)
+ (166.0, 0.03)
+ (171.0, 0.03)
+ (174.0, 0.03)
+ (189.0, 0.04)
+ (190.0, 0.04)
+ (191.0, 0.07)
+ (192.0, 0.05)
+ (194.0, 0.04)
+ (196.0, 0.04)
+ (198.0, 0.04)
+ (206.0, 0.04)
+ (212.0, 0.05)
+ (213.0, 0.04)
+ (216.0, 0.04)
+ (221.0, 0.04)
+ (222.0, 0.05)
+ (226.0, 0.04)
+ (230.0, 0.05)
+ (235.0, 0.07)
+ (243.0, 0.10)
+ (251.0, 0.06)
+ (255.0, 0.06)
+ (256.0, 0.06)
+ (266.0, 0.06)
+ (285.0, 0.06)
+ (291.0, 0.07)
+ (321.0, 0.10)
+ (336.0, 0.10)
+ (338.0, 0.10)
+ (369.0, 0.15)
+ (379.0, 0.13)
+ (382.0, 0.23)
+ (384.0, 0.15)
+ (401.0, 0.15)
+ (414.0, 0.20)
+ (416.0, 0.12)
+ (444.0, 0.16)
+ (448.0, 0.12)
+ (450.0, 0.12)
+ (452.0, 0.16)
+ (468.0, 0.17)
+ (480.0, 0.15)
+ (488.0, 0.55)
+ (489.0, 0.20)
+ (495.0, 0.19)
+ (511.0, 0.24)
+ (512.0, 0.24)
+ (521.0, 0.25)
};
- \addlegendentry{fiat\_solinas64}
+ \addlegendentry{ours, Solinas reduction}
- \addplot[color=red,mark=ball*] coordinates {
- (127, 0.15)
- (129, 0.27)
- (130, 0.27)
- (137, 0.27)
- (140, 0.27)
- (141, 0.27)
- (150, 0.27)
- (152, 0.27)
- (158, 0.27)
- (165, 0.27)
- (166, 0.27)
- (171, 0.27)
- (174, 0.27)
- (189, 0.28)
- (190, 0.27)
- (191, 0.26)
- (192, 0.24)
- (194, 0.35)
- (196, 0.34)
- (198, 0.34)
- (205, 0.34)
- (206, 0.34)
- (212, 0.35)
- (213, 0.35)
- (216, 0.35)
- (221, 0.35)
- (222, 0.34)
- (224, 0.35)
- (226, 0.34)
- (230, 0.34)
- (235, 0.34)
- (243, 0.34)
- (251, 0.35)
- (254, 0.35)
- (255, 0.33)
- (256, 0.34)
- (266, 0.43)
- (285, 0.43)
- (291, 0.43)
- (321, 0.52)
- (322, 0.52)
- (336, 0.53)
- (338, 0.53)
- (369, 0.53)
- (379, 0.53)
- (382, 0.53)
- (383, 0.50)
- (384, 0.47)
- (389, 0.59)
- (401, 0.60)
- (413, 0.61)
- (414, 0.60)
- (416, 0.60)
- (444, 0.60)
- (448, 0.53)
- (450, 0.69)
- (452, 0.68)
- (468, 0.69)
- (480, 0.69)
- (488, 0.69)
- (489, 0.69)
- (495, 0.69)
- (510, 0.69)
- (511, 0.65)
- (512, 0.63)
- (521, 0.81)
+ \addplot[color=red,mark=*] coordinates {
+ (127.0, 0.15)
+ (129.0, 0.27)
+ (130.0, 0.27)
+ (137.0, 0.27)
+ (140.0, 0.27)
+ (141.0, 0.27)
+ (150.0, 0.27)
+ (152.0, 0.27)
+ (158.0, 0.27)
+ (165.0, 0.27)
+ (166.0, 0.27)
+ (171.0, 0.27)
+ (174.0, 0.27)
+ (189.0, 0.28)
+ (190.0, 0.27)
+ (191.0, 0.26)
+ (192.0, 0.24)
+ (194.0, 0.35)
+ (196.0, 0.34)
+ (198.0, 0.34)
+ (204.37503943134692, 0.34)
+ (206.0, 0.34)
+ (212.0, 0.35)
+ (213.0, 0.35)
+ (216.0, 0.35)
+ (221.0, 0.35)
+ (222.0, 0.34)
+ (224.0, 0.35)
+ (226.0, 0.34)
+ (230.0, 0.34)
+ (235.0, 0.34)
+ (243.0, 0.34)
+ (251.0, 0.35)
+ (253.98877343250717, 0.35)
+ (255.0, 0.33)
+ (256.0, 0.34)
+ (255.99999999966408, 0.33)
+ (255.9980614856364, 0.34)
+ (266.0, 0.43)
+ (285.0, 0.43)
+ (291.0, 0.43)
+ (321.0, 0.52)
+ (322.0, 0.52)
+ (336.0, 0.53)
+ (338.0, 0.53)
+ (369.0, 0.53)
+ (379.0, 0.53)
+ (382.0, 0.53)
+ (383.0, 0.50)
+ (384.0, 0.47)
+ (383.9998899269044, 0.46)
+ (383.467605550083, 0.46)
+ (389.0, 0.59)
+ (401.0, 0.60)
+ (413.0, 0.61)
+ (414.0, 0.60)
+ (416.0, 0.60)
+ (444.0, 0.60)
+ (448.0, 0.53)
+ (450.0, 0.69)
+ (452.0, 0.68)
+ (468.0, 0.69)
+ (480.0, 0.69)
+ (488.0, 0.69)
+ (489.0, 0.69)
+ (495.0, 0.69)
+ (509.97423531735535, 0.69)
+ (511.0, 0.65)
+ (511.9891505409899, 0.63)
+ (512.0, 0.62)
+ (521.0, 0.81)
};
- \addlegendentry{gmpvar}
+ \addlegendentry{GMP mpn\_ API}
\addplot[color=red,mark=o] coordinates {
- (127, 0.61)
- (129, 0.79)
- (130, 0.78)
- (137, 0.81)
- (140, 0.81)
- (141, 0.81)
- (150, 0.80)
- (152, 0.80)
- (158, 0.76)
- (165, 0.79)
- (166, 0.78)
- (171, 0.79)
- (174, 0.78)
- (189, 0.79)
- (190, 0.78)
- (191, 0.77)
- (192, 0.71)
- (194, 0.93)
- (196, 0.87)
- (198, 0.86)
- (205, 0.84)
- (206, 0.86)
- (212, 0.88)
- (213, 0.88)
- (216, 0.86)
- (221, 0.88)
- (222, 0.88)
- (224, 0.86)
- (226, 0.90)
- (230, 0.88)
- (235, 0.88)
- (243, 0.89)
- (251, 0.90)
- (254, 0.90)
- (255, 0.87)
- (256, 0.85)
- (266, 0.98)
- (285, 0.97)
- (291, 0.99)
- (321, 1.16)
- (322, 1.13)
- (336, 1.07)
- (338, 1.06)
- (369, 1.06)
- (379, 1.07)
- (382, 1.08)
- (383, 1.04)
- (384, 0.97)
- (389, 1.18)
- (401, 1.16)
- (413, 1.17)
- (414, 1.16)
- (416, 1.17)
- (444, 1.17)
- (448, 1.05)
- (450, 1.34)
- (452, 1.29)
- (468, 1.26)
- (480, 1.27)
- (488, 1.27)
- (489, 1.27)
- (495, 1.29)
- (510, 1.26)
- (511, 1.22)
- (512, 1.15)
- (521, 1.39)
+ (127.0, 0.61)
+ (129.0, 0.79)
+ (130.0, 0.78)
+ (137.0, 0.81)
+ (140.0, 0.81)
+ (141.0, 0.81)
+ (150.0, 0.80)
+ (152.0, 0.80)
+ (158.0, 0.76)
+ (165.0, 0.79)
+ (166.0, 0.78)
+ (171.0, 0.79)
+ (174.0, 0.78)
+ (189.0, 0.79)
+ (190.0, 0.78)
+ (191.0, 0.77)
+ (192.0, 0.71)
+ (194.0, 0.93)
+ (196.0, 0.87)
+ (198.0, 0.86)
+ (204.37503943134692, 0.84)
+ (206.0, 0.86)
+ (212.0, 0.88)
+ (213.0, 0.88)
+ (216.0, 0.86)
+ (221.0, 0.88)
+ (222.0, 0.88)
+ (224.0, 0.86)
+ (226.0, 0.90)
+ (230.0, 0.88)
+ (235.0, 0.88)
+ (243.0, 0.89)
+ (251.0, 0.90)
+ (253.98877343250717, 0.90)
+ (255.0, 0.87)
+ (256.0, 0.85)
+ (255.99999999966408, 0.85)
+ (255.9980614856364, 0.86)
+ (266.0, 0.98)
+ (285.0, 0.97)
+ (291.0, 0.99)
+ (321.0, 1.16)
+ (322.0, 1.13)
+ (336.0, 1.07)
+ (338.0, 1.06)
+ (369.0, 1.06)
+ (379.0, 1.07)
+ (382.0, 1.08)
+ (383.0, 1.04)
+ (384.0, 0.97)
+ (383.9998899269044, 0.97)
+ (383.467605550083, 0.96)
+ (389.0, 1.18)
+ (401.0, 1.16)
+ (413.0, 1.17)
+ (414.0, 1.16)
+ (416.0, 1.17)
+ (444.0, 1.17)
+ (448.0, 1.05)
+ (450.0, 1.34)
+ (452.0, 1.29)
+ (468.0, 1.26)
+ (480.0, 1.27)
+ (488.0, 1.27)
+ (489.0, 1.27)
+ (495.0, 1.29)
+ (509.97423531735535, 1.26)
+ (511.0, 1.22)
+ (511.9891505409899, 1.15)
+ (512.0, 1.14)
+ (521.0, 1.39)
};
- \addlegendentry{gmpxx}
+ \addlegendentry{GMP C++ API}
- \addplot[color=red,mark=*] coordinates {
- (127, 0.27)
- (129, 0.38)
- (130, 0.38)
- (137, 0.38)
- (140, 0.38)
- (141, 0.38)
- (150, 0.38)
- (152, 0.38)
- (158, 0.38)
- (165, 0.38)
- (166, 0.38)
- (171, 0.38)
- (174, 0.38)
- (189, 0.38)
- (190, 0.38)
- (191, 0.36)
- (192, 0.28)
- (194, 0.50)
- (196, 0.50)
- (198, 0.50)
- (205, 0.49)
- (206, 0.50)
- (212, 0.50)
- (213, 0.50)
- (216, 0.50)
- (221, 0.50)
- (222, 0.50)
- (224, 0.50)
- (226, 0.50)
- (230, 0.49)
- (235, 0.50)
- (243, 0.50)
- (251, 0.50)
- (254, 0.50)
- (255, 0.48)
- (256, 0.38)
- (266, 0.64)
- (285, 0.65)
- (291, 0.64)
- (321, 0.80)
- (322, 0.81)
- (336, 0.80)
- (338, 0.79)
- (369, 0.79)
- (379, 0.80)
- (382, 0.81)
- (383, 0.75)
- (384, 0.63)
- (389, 0.96)
- (401, 0.97)
- (413, 0.97)
- (414, 0.96)
- (416, 0.96)
- (444, 0.96)
- (448, 0.77)
- (450, 1.17)
- (452, 1.17)
- (468, 1.17)
- (480, 1.17)
- (488, 1.16)
- (489, 1.17)
- (495, 1.16)
- (510, 1.17)
- (511, 1.11)
- (512, 0.95)
- (521, 1.41)
+ \addplot[color=red,mark=x] coordinates {
+ (127.0, 0.27)
+ (129.0, 0.38)
+ (130.0, 0.38)
+ (137.0, 0.38)
+ (140.0, 0.38)
+ (141.0, 0.38)
+ (150.0, 0.38)
+ (152.0, 0.38)
+ (158.0, 0.38)
+ (165.0, 0.38)
+ (166.0, 0.38)
+ (171.0, 0.38)
+ (174.0, 0.38)
+ (189.0, 0.38)
+ (190.0, 0.38)
+ (191.0, 0.36)
+ (192.0, 0.28)
+ (194.0, 0.50)
+ (196.0, 0.50)
+ (198.0, 0.50)
+ (204.37503943134692, 0.49)
+ (206.0, 0.50)
+ (212.0, 0.50)
+ (213.0, 0.50)
+ (216.0, 0.50)
+ (221.0, 0.50)
+ (222.0, 0.50)
+ (224.0, 0.50)
+ (226.0, 0.50)
+ (230.0, 0.49)
+ (235.0, 0.50)
+ (243.0, 0.50)
+ (251.0, 0.50)
+ (253.98877343250717, 0.50)
+ (255.0, 0.48)
+ (256.0, 0.38)
+ (255.99999999966408, 0.37)
+ (255.9980614856364, 0.37)
+ (266.0, 0.64)
+ (285.0, 0.65)
+ (291.0, 0.64)
+ (321.0, 0.80)
+ (322.0, 0.81)
+ (336.0, 0.80)
+ (338.0, 0.79)
+ (369.0, 0.79)
+ (379.0, 0.80)
+ (382.0, 0.81)
+ (383.0, 0.75)
+ (384.0, 0.63)
+ (383.9998899269044, 0.62)
+ (383.467605550083, 0.62)
+ (389.0, 0.96)
+ (401.0, 0.97)
+ (413.0, 0.97)
+ (414.0, 0.96)
+ (416.0, 0.96)
+ (444.0, 0.96)
+ (448.0, 0.77)
+ (450.0, 1.17)
+ (452.0, 1.17)
+ (468.0, 1.17)
+ (480.0, 1.17)
+ (488.0, 1.16)
+ (489.0, 1.17)
+ (495.0, 1.16)
+ (509.97423531735535, 1.17)
+ (511.0, 1.11)
+ (511.9891505409899, 0.95)
+ (512.0, 0.96)
+ (521.0, 1.41)
};
- \addlegendentry{gmpsec}
-
+ \addlegendentry{GMP mpn\_sec API}
- \end{axis}
- \end{figure*}
-
+ \end{axis}
+\end{tikzpicture}
+\end{figure*}
diff --git a/measurements/tolatex.py b/measurements/tolatex.py
index 73ec7fa3a..845866e8f 100644
--- a/measurements/tolatex.py
+++ b/measurements/tolatex.py
@@ -3,7 +3,7 @@
#
# This ignores duplicate entries, including different primes with the same
# number of bits.
-import sys
+import sys, math
USAGE = "USAGE: python tolatex.py [input file]"
@@ -12,11 +12,26 @@ SETUPS = {
"fiat_montgomery64": "color=blue,mark=square*",
"fiat_solinas32": "color=blue,mark=triangle",
"fiat_solinas64": "color=blue,mark=square",
- "gmpvar": "color=red,mark=ball*",
+ "gmpvar": "color=red,mark=*",
"gmpxx": "color=red,mark=o",
- "gmpsec" : "color=red,mark=*"
+ "gmpsec" : "color=red,mark=x"
}
+LEGEND = {
+ "fiat_montgomery32": "ours, Montgomery reduction",
+ "fiat_montgomery64": "ours, Montgomery reduction",
+ "fiat_solinas32": "ours, Solinas reduction",
+ "fiat_solinas64": "ours, Solinas reduction",
+ "gmpvar": "GMP mpn_ API",
+ "gmpxx": "GMP C++ API",
+ "gmpsec" : "GMP mpn_sec API"
+ }
+
+EXCLUDE = [
+ "fiat_montgomery32",
+ "fiat_solinas32"
+ ]
+
class ParseException(Exception): pass
def parse_line(line):
@@ -28,39 +43,74 @@ def parse_line(line):
"setup" : data[1],
"time" : data[2] }
-# remove duplicates, reorganize, and parse number of bits from primes
+# given a string representing one term or "tap" in a prime, returns a pair of
+# integers representing the weight and coefficient of that tap
+# "2 ^ y" -> [1, y]
+# "x * 2 ^ y" -> [x, y]
+# "x * y" -> [x*y,0]
+# "x" -> [x,0]
+def parse_term(t) :
+ if "*" not in t and "^" not in t:
+ return [int(t),0]
+
+ if "*" in t:
+ if len(t.split("*")) > 2: # this occurs when e.g. [w - x * y] has been turned into [w + -1 * x * y]
+ a1,a2,b = t.split("*")
+ a = int(a1) * int(a2)
+ else:
+ a,b = t.split("*")
+ if "^" not in b:
+ return [int(a) * int(b),0]
+ else:
+ a,b = (1,t)
+
+ b,e = b.split("^")
+ if int(b) != 2:
+ raise NonBase2Exception("Could not parse term, power with base other than 2: %s" %t)
+ return [int(a),int(e)]
+
+# expects prime to be a string and expressed as sum/difference of products of
+# two with small coefficients (e.g. '2^448 - 2^224 - 1', '2^255 - 19')
+def parse_prime(prime):
+ prime = prime.replace("-", "+ -").replace(' ', '').replace('+-2^', '+-1*2^')
+ terms = prime.split("+")
+ return list(map(parse_term, terms))
+
+# remove duplicates, reorganize, and parse primes
def clean_data(parsed_lines):
out = {s:{} for s in SETUPS}
for ln in parsed_lines:
- nbits = ln["prime"].split("2e")[1].split("m")[0].split("p")[0]
+ prime2 = ln["prime"].replace("e", "^").replace("m", "-").replace("p","+").replace("x","*")
+ p = sum([(x * (2**e)) for x,e in parse_prime(prime2)])
+ n = math.log2(p)
# if some measurement is duplicated, ignore the repeats
- if nbits not in out[ln["setup"]]:
- out[ln["setup"]][nbits] = ln["time"]
+ if n not in out[ln["setup"]]:
+ out[ln["setup"]][n] = ln["time"]
return out
def makeplot(data):
out = """
- \\begin{figure*}
- \\begin{tikzpicture}
- \t\\begin{axis}[
- \t\theight=11cm,
- \t\twidth=\\textwidth,
- \t\tgrid=major,
- \t\tlegend pos= north west,
- \t\txlabel=Prime Size (bits),
- \t\tylabel=Time (seconds)]
- """
+ \\begin{figure*}
+ \\begin{tikzpicture}
+ \t\\begin{axis}[
+ \t\theight=9cm,
+ \t\twidth=\\textwidth,
+ \t\tlegend pos= north west,
+ \t\txtick distance=100,
+ \t\textra x ticks={127,256,448,480},
+ \t\textra x tick style={grid=major, tick label style={rotate=45,anchor=east}},
+ \t\tymin=0,
+ \t\txlabel=log2(prime),
+ \t\tylabel=Time (seconds)]"""
for s in SETUPS:
+ if s in EXCLUDE:
+ continue
out +="\t\t\\addplot[%s] coordinates {\n" %SETUPS[s]
- for nbits in data[s]:
- out += "\t\t\t(%s, %s) \n" %(nbits, data[s][nbits])
+ for n in data[s]:
+ out += "\t\t\t(%s, %s) \n" %(n, data[s][n])
out += "\t\t};\n"
- out += "\t\t\\addlegendentry{%s}\n\n" %s.replace("_", "\_")
- out += """
- \t\end{axis}
- \\end{tikzpicture}
- \\end{figure*}
- """
+ out += "\t\t\\addlegendentry{%s}\n\n" %LEGEND[s].replace("_", "\_")
+ out += "\t\end{axis}\n\\end{tikzpicture}\n\\end{figure*}"
return out
if __name__ == "__main__":