diff options
| author | J08nY | 2017-12-28 20:38:56 +0100 |
|---|---|---|
| committer | J08nY | 2017-12-28 20:38:56 +0100 |
| commit | f0cc9ea002d6e853075e2d99a81d8537e2b2f41f (patch) | |
| tree | ac2bdafdd734bf98c73fa4e8b9a2214219d3df42 /util/plot_dh.py | |
| parent | 70bcab713bcc36f3f6a5886f4651967e1585fad6 (diff) | |
| download | ECTester-f0cc9ea002d6e853075e2d99a81d8537e2b2f41f.tar.gz ECTester-f0cc9ea002d6e853075e2d99a81d8537e2b2f41f.tar.zst ECTester-f0cc9ea002d6e853075e2d99a81d8537e2b2f41f.zip | |
Diffstat (limited to 'util/plot_dh.py')
| -rwxr-xr-x | util/plot_dh.py | 17 |
1 files changed, 15 insertions, 2 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) |
