X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/db082c49480d86a681b6e4d199cafd2ece980293..93c9fc23c87b5d3709be87d0f64f5fca0e424691:/measure_energy_iot/client_tcp4.py diff --git a/measure_energy_iot/client_tcp4.py b/measure_energy_iot/client_tcp4.py index 542a7ae..6485a5d 100644 --- a/measure_energy_iot/client_tcp4.py +++ b/measure_energy_iot/client_tcp4.py @@ -7,7 +7,7 @@ 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 @@ -86,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) @@ -98,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 bmp ",elapsed_time/nb_times) + elapsed_time.append(time.time() - t) + + print("send bmp mean",np.mean(elapsed_time), " std ",np.std(elapsed_time)) - elapsed_time=0 - t=time.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) @@ -114,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 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) @@ -130,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 4 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))