]> AND Private Git Repository - Cipher_code.git/blobdiff - measure_energy_iot/client_tcp4.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] / measure_energy_iot / client_tcp4.py
index a070da9908e14acfe75dc4c9be47bd4ff2305dbd..6485a5dfafc9f447882261ebaebd65a0f92e7847 100644 (file)
@@ -6,6 +6,8 @@ import buffer
 from PIL import Image
 import sys
 from io import BytesIO
+from pathlib import Path
+import numpy as np
 
 HOST = "192.168.0.106"
 PORT = 2345
@@ -31,7 +33,7 @@ for i in range(nb_times):
 
 elapsed_time += time.time() - t
 
-print("time in memory bmp",elapsed_time/nb_times)
+print("compute bmp",elapsed_time/nb_times," / size of file ",Path('lena.bmp').stat().st_size)
 
 
 """
@@ -59,7 +61,7 @@ for i in range(nb_times):
     
 elapsed_time += time.time() - t
 
-print("time noscale jpg",elapsed_time/nb_times)
+print("compute noscale jpg",elapsed_time/nb_times, " / size of file ",Path('lena2.jpg').stat().st_size)
 
 
 
@@ -73,7 +75,7 @@ for i in range(nb_times):
     im2.save(buf, "JPEG", quality=quality)
     
 elapsed_time += time.time() - t
-print("time resize + pil",elapsed_time/nb_times)
+print("compute scale 4 jpg ",elapsed_time/nb_times, " / size of file ",Path('lena3.jpg').stat().st_size)
 
 
 
@@ -84,11 +86,10 @@ with s:
     sbuf = buffer.Buffer(s)
 
 
-    elapsed_time=0
-    t=time.time()
+    elapsed_time=[]
     file_name="lena.bmp"
     for i in range(nb_times):
-#        print(file_name)
+        t=time.time()
         sbuf.put_utf8(file_name)
 
         file_size = os.path.getsize(file_name)
@@ -96,15 +97,14 @@ with s:
 
         with open(file_name, 'rb') as f:
             sbuf.put_bytes(f.read())
-#        print('File Sent')
-    elapsed_time += time.time() - t    
-    print("send lena.bmp ",elapsed_time/nb_times)
+        elapsed_time.append(time.time() - t)
 
-    elapsed_time=0
-    t=time.time()
+    print("send bmp mean",np.mean(elapsed_time), " std ",np.std(elapsed_time))
+
+    elapsed_time=[]
     file_name="lena2.jpg"
     for i in range(nb_times):
#       print(file_name)
       t=time.time()
         sbuf.put_utf8(file_name)
 
         file_size = os.path.getsize(file_name)
@@ -112,15 +112,15 @@ with s:
 
         with open(file_name, 'rb') as f:
             sbuf.put_bytes(f.read())
- #       print('File Sent')
-    elapsed_time += time.time() - t    
-    print("send noscale lena2.jpg ",elapsed_time/nb_times)
+        elapsed_time.append(time.time() - t)
+
+    print("send noscale jpg   mean",np.mean(elapsed_time), " std ",np.std(elapsed_time))
+
+    elapsed_time=[]
 
-    elapsed_time=0
-    t=time.time()
     file_name="lena3.jpg"
     for i in range(nb_times):
#       print(file_name)
       t=time.time()
         sbuf.put_utf8(file_name)
 
         file_size = os.path.getsize(file_name)
@@ -128,7 +128,7 @@ with s:
 
         with open(file_name, 'rb') as f:
             sbuf.put_bytes(f.read())
#       print('File Sent')
-    elapsed_time += time.time() - t    
-    print("send scale lena3.jpg ",elapsed_time/nb_times)
       elapsed_time.append(time.time() - t)
+
+    print("send scale 4 jpg  mean",np.mean(elapsed_time), " std ",np.std(elapsed_time))