]> AND Private Git Repository - Cipher_code.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
up
authorRaphaël Couturier <raphael.couturier@univ-fcomte.fr>
Tue, 13 Jul 2021 19:16:57 +0000 (21:16 +0200)
committerRaphaël Couturier <raphael.couturier@univ-fcomte.fr>
Tue, 13 Jul 2021 19:16:57 +0000 (21:16 +0200)
measure_energy_iot/client_tcp4.py
measure_energy_iot/lena2.jpg
measure_energy_iot/server_tcp4.py

index f8b73f0baea1514a8a3a08391cbc0a221a515296..0944d1e2ac95490e4d3c8236faa644b3b932750a 100644 (file)
@@ -3,22 +3,86 @@ import threading
 import os
 import time
 import buffer
 import os
 import time
 import buffer
+from PIL import Image
+import sys
+from io import BytesIO
 
 
-HOST = 'bilbo'
+HOST = "192.168.0.106"
 PORT = 2345
 
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.connect((HOST, PORT))
 
 PORT = 2345
 
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.connect((HOST, PORT))
 
+nb_times=100
+
+quality=int(sys.argv[1])
+print("quality ",quality)
+
+
+
+
+im=Image.open("lena.jpg")
+im.save("lena.bmp",quality=quality)
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+    buf = BytesIO()
+    im.save(buf, "JPEG", quality=quality)
+
+elapsed_time += time.time() - t
+
+print("time in memory bmp",elapsed_time/nb_times)
+
+
+
+im=Image.open("lena.jpg")
+
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+    im.save("lena.bmp",quality=quality)
+
+elapsed_time += time.time() - t
+
+print("time bmp",elapsed_time/nb_times)
+
+
+
+
+im=Image.open("lena.jpg")
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+
+    im.save("lena2.jpg",quality=quality)
+elapsed_time += time.time() - t
+
+print("time noscale jpg",elapsed_time/nb_times)
+
+
+
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+    im2=im.resize((256, 256))
+    im2.save("lena3.jpg",quality=quality)
+elapsed_time += time.time() - t
+print("time resize + pil",elapsed_time/nb_times)
+
+
+
+
+
+
 with s:
     sbuf = buffer.Buffer(s)
 
 
     elapsed_time=0
     t=time.time()
 with s:
     sbuf = buffer.Buffer(s)
 
 
     elapsed_time=0
     t=time.time()
-    file_name="lena.jpg"
-    for i in range(10):
-        print(file_name)
+    file_name="lena.bmp"
+    for i in range(nb_times):
+#        print(file_name)
         sbuf.put_utf8(file_name)
 
         file_size = os.path.getsize(file_name)
         sbuf.put_utf8(file_name)
 
         file_size = os.path.getsize(file_name)
@@ -26,15 +90,15 @@ with s:
 
         with open(file_name, 'rb') as f:
             sbuf.put_bytes(f.read())
 
         with open(file_name, 'rb') as f:
             sbuf.put_bytes(f.read())
-        print('File Sent')
+#        print('File Sent')
     elapsed_time += time.time() - t    
     elapsed_time += time.time() - t    
-    print("send lena ",elapsed_time)
+    print("send lena.bmp ",elapsed_time/nb_times)
 
     elapsed_time=0
     t=time.time()
     file_name="lena2.jpg"
 
     elapsed_time=0
     t=time.time()
     file_name="lena2.jpg"
-    for i in range(10):
-        print(file_name)
+    for i in range(nb_times):
#       print(file_name)
         sbuf.put_utf8(file_name)
 
         file_size = os.path.getsize(file_name)
         sbuf.put_utf8(file_name)
 
         file_size = os.path.getsize(file_name)
@@ -42,8 +106,23 @@ with s:
 
         with open(file_name, 'rb') as f:
             sbuf.put_bytes(f.read())
 
         with open(file_name, 'rb') as f:
             sbuf.put_bytes(f.read())
-        print('File Sent')
#       print('File Sent')
     elapsed_time += time.time() - t    
     elapsed_time += time.time() - t    
-    print("send lena ",elapsed_time)
+    print("send noscale lena2.jpg ",elapsed_time/nb_times)
 
 
+    elapsed_time=0
+    t=time.time()
+    file_name="lena3.jpg"
+    for i in range(nb_times):
+ #       print(file_name)
+        sbuf.put_utf8(file_name)
+
+        file_size = os.path.getsize(file_name)
+        sbuf.put_utf8(str(file_size))
+
+        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)
 
 
index 56801436f245584e5c2fdbacf039e77c06e20cca..866507b78bbd50ea25e95d383a3b5504d990ce78 100644 (file)
Binary files a/measure_energy_iot/lena2.jpg and b/measure_energy_iot/lena2.jpg differ
index 52c3afd7cca515351934f3a236763cdb0d199854..0f078bc949fdc1be9c040529c9f5d1f264fb4a46 100644 (file)
@@ -3,7 +3,7 @@ import os
 
 import buffer
 
 
 import buffer
 
-HOST = 'bilbo'
+HOST = ''
 PORT = 2345
 
 # If server and client run in same local directory,
 PORT = 2345
 
 # If server and client run in same local directory,