]> AND Private Git Repository - Cipher_code.git/blob - OneRoundIoT/execution_time.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Merge branch 'master' of ssh://info.iut-bm.univ-fcomte.fr/Cipher_code
[Cipher_code.git] / OneRoundIoT / execution_time.py
1 import matplotlib.pyplot as plt
2 import matplotlib
3 matplotlib.use('Agg')
4 from ggplot import *
5 import numpy as np
6 import pandas as pd
7 from math import log
8 from matplotlib import style
9 from matplotlib import style
10 import time
11 import tkinter as tk
12 from tkinter import filedialog
13 import ntpath
14 from cycler import cycler
15 ntpath.basename("a/b/c")
16
17
18
19
20 def path_leaf(path):
21     head, tail = ntpath.split(path)
22     return tail or ntpath.basename(head)
23
24
25 # Function is used to get the file-path
26
27 def uigetfileUserfunction():
28         root = tk.Tk()
29         root.withdraw()
30         file_path = filedialog.askopenfilename()
31         return file_path 
32
33
34
35 def uipostfileUserfunction():
36         root = tk.Tk()
37         root.withdraw()
38         root.filename =  filedialog.asksaveasfilename(initialdir = "/hn",title = "Select file",filetypes = (("text files","*.eps"),("all files","*.*")))
39         #print (root.filename)
40         resss=path_leaf(root.filename)
41        # resss=root.filename
42         print (resss)
43         return resss
44
45
46
47 def plotResults(h,dataf,filename):
48         #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
49         # Build the figure and its corresponding parameters
50         #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
51             # use ggplot style sheet
52     style.use('ggplot')
53     beingsaved = plt.figure(figsize=(8, 8))
54     plt.loglog(h,dataf)
55     plt.yscale('log')
56     plt.xlabel('Buffer Size')
57     plt.ylabel('Execution Time')
58     plt.legend(["Dynamic ECB Encryption", "Dynamic ECB Decryption", "Dynamic CTR ENCRYPTION",
59                         "Dynamic CTR DECRYPTION","OpenSSL ECB Encryption"," OpenSSL Decryption ECB",
60                         "OpenSSL Encryption CTR","OPENSSL Decryption CTR"],loc='best')
61     matplotlib.rcParams.update({'font.size': 22})
62     plt.grid(True,which="both",ls="-")
63     plt.title('')
64     beingsaved.savefig(filename, format='eps', dpi=1000)
65     filename=filename[0:len(filename)-4]+'.png'
66     beingsaved.savefig(filename, format='png', dpi=1000)
67     plt.show()
68     
69         
70         
71
72
73
74
75
76  # Get the first file-path name   
77 str1=uigetfileUserfunction()
78  # Get the second -path name  
79 str2=uigetfileUserfunction()
80 '''
81 #data = np.genfromtxt('execution_oneround_opi.txt')
82 #data3 = np.genfromtxt('execution_openssl_opi.txt')4
83 '''
84 # Read the first filename
85 data = np.genfromtxt(str1)
86 # Eliminate the first column
87 data2 = np.delete(data, 0, 1)  # delete first column of C
88
89 # Read the second filename
90 data3 = np.genfromtxt(str2)
91 data4 = np.delete(data3, 0, 1)  # delete first column of C
92
93 # Concatenate the both matrices (column-wise)
94 dataf=np.hstack((data2, data4))
95 print(dataf,type(dataf))
96
97 # Initialization the h vector
98 h=np.asarray([16,64,256,1024,4096,16384,65536, 262144])
99
100 filename=uipostfileUserfunction()
101 print (filename)
102 # Call the plotResults function
103 #filetoStore='hello'
104 plotResults(h,dataf,filename)
105
106
107