summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorJ08nY2017-12-28 17:53:05 +0100
committerJ08nY2017-12-28 17:53:05 +0100
commit552289fd86446416eefec6356659a8333d091f79 (patch)
treec29f7c0b6b2b2af0929cbb6b9da6355a3cfd25c2 /util
parentdbd448f1c325b39789cafc81615b6ed010b19bb5 (diff)
downloadECTester-552289fd86446416eefec6356659a8333d091f79.tar.gz
ECTester-552289fd86446416eefec6356659a8333d091f79.tar.zst
ECTester-552289fd86446416eefec6356659a8333d091f79.zip
Diffstat (limited to 'util')
-rwxr-xr-xutil/plot_dh.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/util/plot_dh.py b/util/plot_dh.py
new file mode 100755
index 0000000..eb1886a
--- /dev/null
+++ b/util/plot_dh.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+#
+# Script for plotting ECTester ECDH results.
+#
+# Example usage:
+#
+# > java -jar ECTesterReader.jar -dh 10000 -b 192 -fp -o dh.csv
+# ...
+# > ./plot_dh.py dh.csv
+# ...
+#
+
+import numpy as np
+import matplotlib.pyplot as plt
+import argparse
+from operator import itemgetter
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description="Plot ECTester ECDH timing.")
+ parser.add_argument("-o", "--output", dest="output", type=argparse.FileType("wb"), help="Write image to [file], do not display.", metavar="file")
+ parser.add_argument("file", type=str, help="The file to plot(csv).")
+
+ opts = parser.parse_args()
+
+ 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)
+ priv_data = map(itemgetter(2), data)
+ pub_data = map(itemgetter(3), data)
+ secret_data = map(itemgetter(4), data)
+
+ fig = plt.figure(tight_layout=True)
+ fig.suptitle(opts.file)
+
+ axe_hist = fig.add_subplot(1,1,1)
+ axe_hist.hist(time_data, bins=400, log=True)
+ axe_hist.set_ylabel("count\n(log)")
+ axe_hist.set_xlabel("time (ms)")
+
+ if opts.output is None:
+ plt.show()
+ else:
+ plt.savefig(opts.output, dpi=400)