summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2017-12-28 20:38:56 +0100
committerJ08nY2017-12-28 20:38:56 +0100
commitf0cc9ea002d6e853075e2d99a81d8537e2b2f41f (patch)
treeac2bdafdd734bf98c73fa4e8b9a2214219d3df42
parent70bcab713bcc36f3f6a5886f4651967e1585fad6 (diff)
downloadECTester-f0cc9ea002d6e853075e2d99a81d8537e2b2f41f.tar.gz
ECTester-f0cc9ea002d6e853075e2d99a81d8537e2b2f41f.tar.zst
ECTester-f0cc9ea002d6e853075e2d99a81d8537e2b2f41f.zip
-rwxr-xr-xutil/plot_dh.py17
-rwxr-xr-xutil/plot_gen.py21
2 files changed, 32 insertions, 6 deletions
diff --git a/util/plot_dh.py b/util/plot_dh.py
index 62a2f86..2aa7d21 100755
--- a/util/plot_dh.py
+++ b/util/plot_dh.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
#
# Script for plotting ECTester ECDH results.
#
@@ -23,10 +24,19 @@ if __name__ == "__main__":
opts = parser.parse_args()
+ with open(opts.file, "r") as f:
+ header = f.readline()
+ header_names = header.split(";")
+
hx = lambda x: int(x, 16)
data = np.genfromtxt(opts.file, delimiter=";", skip_header=1, converters={2: hx, 3: hx, 4: hx}, dtype=np.dtype([("index","u4"), ("time","u4"), ("pub", "O"), ("priv", "O"), ("secret","O")]))
- time_data = map(itemgetter(1), data)
+ if "nano" in header_names[1]:
+ unit = r"$\mu s$"
+ time_data = map(lambda x: x[1]/1000, data)
+ else:
+ unit = r"ms"
+ time_data = map(itemgetter(1), data)
priv_data = map(itemgetter(2), data)
pub_data = map(itemgetter(3), data)
secret_data = map(itemgetter(4), data)
@@ -42,11 +52,14 @@ if __name__ == "__main__":
axe_hist.axvline(x=time_avg, alpha=0.7, linestyle="dotted", color="red", label="avg = {}".format(time_avg))
axe_hist.axvline(x=time_median, alpha=0.7, linestyle="dotted", color="green", label="median = {}".format(time_median))
axe_hist.set_ylabel("count\n(log)")
- axe_hist.set_xlabel("time (ms)")
+ axe_hist.set_xlabel("time ({})".format(unit))
axe_hist.xaxis.set_major_locator(ticker.MaxNLocator())
axe_hist.legend(loc="best")
+ fig.text(0.01, 0.02, "Data size: {}".format(len(time_data)), size="small")
+
if opts.output is None:
plt.show()
else:
+ fig.set_size_inches(12, 10)
plt.savefig(opts.output, dpi=400)
diff --git a/util/plot_gen.py b/util/plot_gen.py
index 00892b5..db78f8d 100755
--- a/util/plot_gen.py
+++ b/util/plot_gen.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
#
# Script for plotting ECTester key generation results.
#
@@ -26,6 +27,10 @@ if __name__ == "__main__":
opts = parser.parse_args()
+ with open(opts.file, "r") as f:
+ header = f.readline()
+ header_names = header.split(";")
+
plots = [opts.priv, opts.pub, opts.hist]
n_plots = sum(plots)
if n_plots == 0:
@@ -35,7 +40,12 @@ if __name__ == "__main__":
hx = lambda x: int(x, 16)
data = np.genfromtxt(opts.file, delimiter=";", skip_header=1, converters={2: hx, 3: hx}, dtype=np.dtype([("index","u4"), ("time","u4"), ("pub", "O"), ("priv", "O")]))
- time_data = map(itemgetter(1), data)
+ if "nano" in header_names[1]:
+ unit = r"$\mu s$"
+ time_data = map(lambda x: x[1]/1000, data)
+ else:
+ unit = r"ms"
+ time_data = map(itemgetter(1), data)
priv_data = map(itemgetter(2), data)
pub_data = map(itemgetter(3), data)
@@ -47,14 +57,14 @@ if __name__ == "__main__":
axe_private = fig.add_subplot(n_plots, 1, plot_i)
axe_private.scatter(time_data, priv_data, marker="x", s=10)
axe_private.set_ylabel("private key value\n(big endian)")
- axe_private.set_xlabel("time (ms)")
+ axe_private.set_xlabel("time ({})".format(unit))
plot_i += 1
if plots[1]:
axe_public = fig.add_subplot(n_plots, 1, plot_i)
axe_public.scatter(time_data, pub_data, marker="x", s=10)
axe_public.set_ylabel("public key value\n(big endian)")
- axe_public.set_xlabel("time (ms)")
+ axe_public.set_xlabel("time ({})".format(unit))
plot_i += 1
if plots[2]:
@@ -66,11 +76,14 @@ if __name__ == "__main__":
axe_hist.axvline(x=time_avg, alpha=0.7, linestyle="dotted", color="red", label="avg = {}".format(time_avg))
axe_hist.axvline(x=time_median, alpha=0.7, linestyle="dotted", color="green", label="median = {}".format(time_median))
axe_hist.set_ylabel("count\n(log)")
- axe_hist.set_xlabel("time (ms)")
+ axe_hist.set_xlabel("time ({})".format(unit))
axe_hist.xaxis.set_major_locator(ticker.MaxNLocator())
axe_hist.legend(loc="best")
+ fig.text(0.01, 0.02, "Data size: {}".format(len(time_data)), size="small")
+
if opts.output is None:
plt.show()
else:
+ fig.set_size_inches(12, 10)
plt.savefig(opts.output, dpi=400)