]> AND Private Git Repository - Cipher_code.git/blobdiff - measure_energy_iot/client_tcp4.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new
[Cipher_code.git] / measure_energy_iot / client_tcp4.py
index 0944d1e2ac95490e4d3c8236faa644b3b932750a..542a7ae3c6dd26e24372e9d06c40cd538b927036 100644 (file)
@@ -6,6 +6,8 @@ import buffer
 from PIL import Image
 import sys
 from io import BytesIO
+from pathlib import Path
+
 
 HOST = "192.168.0.106"
 PORT = 2345
@@ -27,14 +29,14 @@ elapsed_time=0
 t = time.time()
 for i in range(nb_times):
     buf = BytesIO()
-    im.save(buf, "JPEG", quality=quality)
+    im.save(buf, "BMP", quality=quality)
 
 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)
 
 
+"""
 im=Image.open("lena.jpg")
 
 elapsed_time=0
@@ -45,29 +47,35 @@ for i in range(nb_times):
 elapsed_time += time.time() - t
 
 print("time bmp",elapsed_time/nb_times)
-
+"""
 
 
 
 im=Image.open("lena.jpg")
 elapsed_time=0
+im.save("lena2.jpg",quality=quality)
 t = time.time()
 for i in range(nb_times):
-
-    im.save("lena2.jpg",quality=quality)
+    buf = BytesIO()
+    im.save(buf, "JPEG", quality=quality)
+    
 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)
 
 
 
 elapsed_time=0
+im2=im.resize((256, 256))
+im2.save("lena3.jpg",quality=quality)
 t = time.time()
 for i in range(nb_times):
     im2=im.resize((256, 256))
-    im2.save("lena3.jpg",quality=quality)
+    buf = BytesIO()
+    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)
 
 
 
@@ -92,7 +100,7 @@ with s:
             sbuf.put_bytes(f.read())
 #        print('File Sent')
     elapsed_time += time.time() - t    
-    print("send lena.bmp ",elapsed_time/nb_times)
+    print("send bmp ",elapsed_time/nb_times)
 
     elapsed_time=0
     t=time.time()
@@ -108,7 +116,7 @@ with s:
             sbuf.put_bytes(f.read())
  #       print('File Sent')
     elapsed_time += time.time() - t    
-    print("send noscale lena2.jpg ",elapsed_time/nb_times)
+    print("send noscale jpg ",elapsed_time/nb_times)
 
     elapsed_time=0
     t=time.time()
@@ -124,5 +132,5 @@ with s:
             sbuf.put_bytes(f.read())
  #       print('File Sent')
     elapsed_time += time.time() - t    
-    print("send scale lena3.jpg ",elapsed_time/nb_times)
+    print("send scale jpg ",elapsed_time/nb_times)