From: hn Date: Wed, 25 Jul 2018 12:33:30 +0000 (+0200) Subject: add of execution_time.py X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/commitdiff_plain/4b7e63289506c9a6883d606c74eb0119046e50d1 add of execution_time.py --- diff --git a/OneRoundIoT/execution_time.py b/OneRoundIoT/execution_time.py new file mode 100644 index 0000000..1271ba4 --- /dev/null +++ b/OneRoundIoT/execution_time.py @@ -0,0 +1,107 @@ +import matplotlib.pyplot as plt +import matplotlib +matplotlib.use('Agg') +from ggplot import * +import numpy as np +import pandas as pd +from math import log +from matplotlib import style +from matplotlib import style +import time +import tkinter as tk +from tkinter import filedialog +import ntpath +from cycler import cycler +ntpath.basename("a/b/c") + + + + +def path_leaf(path): + head, tail = ntpath.split(path) + return tail or ntpath.basename(head) + + +# Function is used to get the file-path + +def uigetfileUserfunction(): + root = tk.Tk() + root.withdraw() + file_path = filedialog.askopenfilename() + return file_path + + + +def uipostfileUserfunction(): + root = tk.Tk() + root.withdraw() + root.filename = filedialog.asksaveasfilename(initialdir = "/hn",title = "Select file",filetypes = (("text files","*.eps"),("all files","*.*"))) + #print (root.filename) + resss=path_leaf(root.filename) + # resss=root.filename + print (resss) + return resss + + + +def plotResults(h,dataf,filename): + #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# + # Build the figure and its corresponding parameters + #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# + # use ggplot style sheet + style.use('ggplot') + beingsaved = plt.figure(figsize=(8, 8)) + plt.loglog(h,dataf) + plt.yscale('log') + plt.xlabel('Buffer Size') + plt.ylabel('Execution Time') + plt.legend(["Dynamic ECB Encryption", "Dynamic ECB Decryption", "Dynamic CTR ENCRYPTION", + "Dynamic CTR DECRYPTION","OpenSSL ECB Encryption"," OpenSSL Decryption ECB", + "OpenSSL Encryption CTR","OPENSSL Decryption CTR"],loc='best') + matplotlib.rcParams.update({'font.size': 22}) + plt.grid(True,which="both",ls="-") + plt.title('') + beingsaved.savefig(filename, format='eps', dpi=1000) + filename=filename[0:len(filename)-4]+'.png' + beingsaved.savefig(filename, format='png', dpi=1000) + plt.show() + + + + + + + + + # Get the first file-path name +str1=uigetfileUserfunction() + # Get the second -path name +str2=uigetfileUserfunction() +''' +#data = np.genfromtxt('execution_oneround_opi.txt') +#data3 = np.genfromtxt('execution_openssl_opi.txt')4 +''' +# Read the first filename +data = np.genfromtxt(str1) +# Eliminate the first column +data2 = np.delete(data, 0, 1) # delete first column of C + +# Read the second filename +data3 = np.genfromtxt(str2) +data4 = np.delete(data3, 0, 1) # delete first column of C + +# Concatenate the both matrices (column-wise) +dataf=np.hstack((data2, data4)) +print(dataf,type(dataf)) + +# Initialization the h vector +h=np.asarray([16,64,256,1024,4096,16384,65536, 262144]) + +filename=uipostfileUserfunction() +print (filename) +# Call the plotResults function +#filetoStore='hello' +plotResults(h,dataf,filename) + + +