Skip to content

Commit 2e32916

Browse files
author
bedogni@unimore.it
committed
Working version
1 parent e89a42c commit 2e32916

18 files changed

+373
-145
lines changed

None

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
inference_id,timestamp,avg_device_time,min_device_time,max_device_time,avg_edge_time,min_edge_time,max_edge_time,num_device_layers,num_edge_layers
2-
1,2026-01-21T19:19:17.471255,0.010910704984503278,0.010067939758300781,0.012644767761230469,0,0,0,59,0
3-
2,2026-01-21T19:19:19.020886,0.011460065841674805,0.011460065841674805,0.011460065841674805,0.0006384972868294552,0.0005071163177490234,0.001268148422241211,1,58
4-
3,2026-01-21T19:19:20.546745,0.01173710823059082,0.01173710823059082,0.01173710823059082,0.0008302187097483668,0.0006759166717529297,0.0027070045471191406,1,58
5-
4,2026-01-21T19:19:22.091189,0.012285947799682617,0.012285947799682617,0.012285947799682617,0.0009110015014122272,0.0006470680236816406,0.0023860931396484375,1,58
6-
5,2026-01-21T19:19:23.617468,0.012113094329833984,0.012113094329833984,0.012113094329833984,0.0008099449091944201,0.0006158351898193359,0.0018260478973388672,1,58
7-
6,2026-01-21T19:19:25.256828,0.011109113693237305,0.011109113693237305,0.011109113693237305,0.0007914304733276367,0.0005650520324707031,0.0013270378112792969,1,58
8-
7,2026-01-21T19:19:26.818955,0.01017308235168457,0.01017308235168457,0.01017308235168457,0.0009169373018988248,0.0006320476531982422,0.002526998519897461,1,58
9-
8,2026-01-21T19:19:28.425736,0.01236104965209961,0.01236104965209961,0.01236104965209961,0.0010416096654431574,0.0007081031799316406,0.005360841751098633,1,58
10-
9,2026-01-21T19:19:29.947933,0.01035308837890625,0.01035308837890625,0.01035308837890625,0.0008198721655483903,0.0006811618804931641,0.0013899803161621094,1,58
11-
10,2026-01-21T19:19:31.451980,0.010391950607299805,0.010391950607299805,0.010391950607299805,0.0008155025284865807,0.0006880760192871094,0.0012340545654296875,1,58
12-
11,2026-01-21T19:19:33.099707,0.012675046920776367,0.012675046920776367,0.012675046920776367,0.0007025578926349508,0.000553131103515625,0.0010211467742919922,1,58
13-
12,2026-01-21T19:19:34.630296,0.010178089141845703,0.010178089141845703,0.010178089141845703,0.0007392168045043945,0.0005629062652587891,0.0016140937805175781,1,58
14-
13,2026-01-21T19:19:36.205286,0.010623931884765625,0.010623931884765625,0.010623931884765625,0.0007768129480296168,0.0005660057067871094,0.001711130142211914,1,58
15-
14,2026-01-21T19:19:37.731927,0.01018524169921875,0.01018524169921875,0.01018524169921875,0.0007240073434237776,0.0005450248718261719,0.0018589496612548828,1,58
16-
15,2026-01-21T19:19:39.266810,0.010265111923217773,0.010265111923217773,0.010265111923217773,0.0007337825051669417,0.0005698204040527344,0.0016589164733886719,1,58
2+
1,2026-02-04T15:49:24.962111,0.011809454125873113,0.010092735290527344,0.012803077697753906,0,0,0,59,0
3+
2,2026-02-04T15:49:26.493623,0.010304927825927734,0.010304927825927734,0.010304927825927734,0.00061744657056085,0.0004999637603759766,0.0011599063873291016,1,58
4+
3,2026-02-04T15:49:27.997687,0.011980772018432617,0.011980772018432617,0.011980772018432617,0.0006725007090075262,0.0005371570587158203,0.0011990070343017578,1,58
5+
4,2026-02-04T15:49:29.497425,0.012717008590698242,0.012717008590698242,0.012717008590698242,0.0006455511882387359,0.0005211830139160156,0.000843048095703125,1,58
6+
5,2026-02-04T15:49:30.999902,0.012842893600463867,0.012842893600463867,0.012842893600463867,0.0006555565472306876,0.0005099773406982422,0.00119781494140625,1,58
7+
6,2026-02-04T15:49:32.509711,0.012573957443237305,0.012573957443237305,0.012573957443237305,0.0006742025243824926,0.0005130767822265625,0.0009589195251464844,1,58
8+
7,2026-02-04T15:49:34.004307,0.010714054107666016,0.010714054107666016,0.010714054107666016,0.000712275505065918,0.0005090236663818359,0.001220703125,1,58
9+
8,2026-02-04T15:49:35.505271,0.010465621948242188,0.010465621948242188,0.010465621948242188,0.0007045885612224711,0.0005021095275878906,0.0009799003601074219,1,58
10+
9,2026-02-04T15:49:37.003349,0.011183738708496094,0.011183738708496094,0.011183738708496094,0.0007283605378249596,0.0005092620849609375,0.0013759136199951172,1,58
11+
10,2026-02-04T15:49:38.490122,0.011852025985717773,0.011852025985717773,0.011852025985717773,0.0006547714101857152,0.0005021095275878906,0.0010399818420410156,1,58
12+
11,2026-02-04T15:49:40.079253,0.011282205581665039,0.011282205581665039,0.011282205581665039,0.0006785844934397731,0.0005238056182861328,0.001238107681274414,1,58
13+
12,2026-02-04T15:49:41.599533,0.012867212295532227,0.012867212295532227,0.012867212295532227,0.000675419281268942,0.0005249977111816406,0.0013461112976074219,1,58
14+
13,2026-02-04T15:49:43.107832,0.013029813766479492,0.013029813766479492,0.013029813766479492,0.0006772649699244006,0.0005290508270263672,0.0015611648559570312,1,58
15+
14,2026-02-04T15:49:44.612841,0.012887954711914062,0.012887954711914062,0.012887954711914062,0.0007193499598009833,0.0005228519439697266,0.0018067359924316406,1,58
16+
15,2026-02-04T15:49:46.113043,0.011921882629394531,0.011921882629394531,0.011921882629394531,0.0007090034156010069,0.0005388259887695312,0.0019199848175048828,1,58
17+
16,2026-02-04T15:49:47.612943,0.012920856475830078,0.012920856475830078,0.012920856475830078,0.0006758837864316743,0.0005352497100830078,0.0014712810516357422,1,58
18+
17,2026-02-04T15:49:49.227098,0.012883901596069336,0.012883901596069336,0.012883901596069336,0.001018853023134429,0.0005309581756591797,0.01961970329284668,1,58
19+
18,2026-02-04T15:49:50.720964,0.011802196502685547,0.011802196502685547,0.011802196502685547,0.0006776431511188375,0.0005331039428710938,0.0011360645294189453,1,58
20+
19,2026-02-04T15:49:52.219665,0.011064767837524414,0.011064767837524414,0.011064767837524414,0.0006408732512901569,0.0005114078521728516,0.0010612010955810547,1,58
21+
20,2026-02-04T15:49:53.712919,0.011616230010986328,0.011616230010986328,0.011616230010986328,0.0006521940231323242,0.0005202293395996094,0.001068115234375,1,58
22+
21,2026-02-04T15:49:55.220580,0.012316226959228516,0.012316226959228516,0.012316226959228516,0.0006290674209594727,0.0005283355712890625,0.0008947849273681641,1,58
23+
22,2026-02-04T15:49:56.741926,0.011439085006713867,0.011439085006713867,0.011439085006713867,0.000652202244462638,0.0005362033843994141,0.0011911392211914062,1,58

analyze_simulation.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def _load_data(self):
7979
with open(config_file, 'r') as f:
8080
self.configs[scenario_name] = json.load(f)
8181
except Exception as e:
82-
print(f" Error loading config for {scenario_name}: {e}")
82+
print(f" WARNING: Error loading config for {scenario_name}: {e}")
8383

8484
def analyze_all(self):
8585
"""Generate all analysis plots"""
86-
print("\n📈 Generating analysis plots...\n")
86+
print("\nGenerating analysis plots...\n")
8787

8888
self.plot_device_vs_edge_time()
8989
self.plot_total_inference_time()
@@ -93,7 +93,7 @@ def analyze_all(self):
9393
self.plot_scenario_comparison()
9494
self.generate_summary_stats()
9595

96-
print(f"\n✅ Analysis complete! Plots saved to: {self.output_dir}\n")
96+
print(f"\nAnalysis complete! Plots saved to: {self.output_dir}\n")
9797

9898
def plot_device_vs_edge_time(self):
9999
"""Compare device vs edge execution times"""
@@ -127,7 +127,7 @@ def plot_device_vs_edge_time(self):
127127
plt.tight_layout()
128128
plt.savefig(self.output_dir / "01_device_vs_edge_time.png", dpi=150, bbox_inches='tight')
129129
plt.close()
130-
print(" Device vs Edge time comparison")
130+
print(" Device vs Edge time comparison")
131131

132132
def plot_total_inference_time(self):
133133
"""Plot total (device + edge) inference time per scenario"""
@@ -160,7 +160,7 @@ def plot_total_inference_time(self):
160160
plt.tight_layout()
161161
plt.savefig(self.output_dir / "02_total_inference_time.png", dpi=150, bbox_inches='tight')
162162
plt.close()
163-
print(" Total inference time comparison")
163+
print(" Total inference time comparison")
164164

165165
def plot_throughput_comparison(self):
166166
"""Plot throughput (inferences per second) for each scenario"""
@@ -206,7 +206,7 @@ def plot_throughput_comparison(self):
206206
plt.tight_layout()
207207
plt.savefig(self.output_dir / "03_throughput_comparison.png", dpi=150, bbox_inches='tight')
208208
plt.close()
209-
print(" Throughput comparison")
209+
print(" Throughput comparison")
210210

211211
def plot_timing_distributions(self):
212212
"""Create boxplots of timing distributions"""
@@ -238,7 +238,7 @@ def plot_timing_distributions(self):
238238
plt.tight_layout()
239239
plt.savefig(self.output_dir / "04_timing_distributions.png", dpi=150, bbox_inches='tight')
240240
plt.close()
241-
print(" Timing distribution boxplots")
241+
print(" Timing distribution boxplots")
242242

243243
def plot_layer_statistics(self):
244244
"""Plot number of layers executed on device vs edge"""
@@ -269,7 +269,7 @@ def plot_layer_statistics(self):
269269
plt.tight_layout()
270270
plt.savefig(self.output_dir / "05_layer_statistics.png", dpi=150, bbox_inches='tight')
271271
plt.close()
272-
print(" Layer statistics comparison")
272+
print(" Layer statistics comparison")
273273

274274
def plot_scenario_comparison(self):
275275
"""Create a comprehensive scenario comparison dashboard"""
@@ -375,7 +375,7 @@ def plot_scenario_comparison(self):
375375
plt.tight_layout()
376376
plt.savefig(self.output_dir / "06_scenario_comparison_dashboard.png", dpi=150, bbox_inches='tight')
377377
plt.close()
378-
print(" Scenario comparison dashboard")
378+
print(" Scenario comparison dashboard")
379379

380380
def generate_summary_stats(self):
381381
"""Generate summary statistics table"""
@@ -453,7 +453,7 @@ def main():
453453
analyzer = SimulationAnalyzer(results_dir)
454454
analyzer.analyze_all()
455455
except Exception as e:
456-
print(f"\n❌ Error: {e}")
456+
print(f"\nERROR: {e}")
457457
import traceback
458458
traceback.print_exc()
459459
sys.exit(1)

example_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
output_path = analyzer.output_dir / "custom_analysis.csv"
173173
custom_df.to_csv(output_path, index=False)
174174

175-
print(f" Exported custom analysis to: {output_path}")
175+
print(f"PASS: Exported custom analysis to: {output_path}")
176176
print("\nCustom analysis data:")
177177
print(custom_df.to_string())
178178

@@ -235,5 +235,5 @@
235235

236236

237237
print("\n" + "=" * 80)
238-
print("All examples completed!")
238+
print("All examples completed!")
239239
print("=" * 80)

generate_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def run_command(cmd, description):
2525
)
2626
if result.stdout:
2727
print(result.stdout)
28-
print(f" {description} completed successfully")
28+
print(f"PASS: {description} completed successfully")
2929
return True
3030
except subprocess.CalledProcessError as e:
31-
print(f" {description} failed with exit code {e.returncode}")
31+
print(f"FAIL: {description} failed with exit code {e.returncode}")
3232
if e.stdout:
3333
print("STDOUT:", e.stdout)
3434
if e.stderr:

logs/DEBUG.log.2025-06-26

Lines changed: 0 additions & 5 deletions
This file was deleted.

logs/INFO.log.2025-06-26

Lines changed: 0 additions & 4 deletions
This file was deleted.

server_client_light/client/http_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def register_device():
6060
print("Registration:", r.status_code, r.text)
6161
return True
6262
except requests.exceptions.RequestException as e:
63-
print(f" Registration failed (server unreachable): {e}")
63+
print(f"WARNING: Registration failed (server unreachable): {e}")
6464
print(" → Continuing with local-only inference")
6565
return False
6666

@@ -89,7 +89,7 @@ def send_image():
8989
print("Image sent:", r.status_code)
9090
return True
9191
except requests.exceptions.RequestException as e:
92-
print(f" Image send failed (server unreachable): {e}")
92+
print(f"WARNING: Image send failed (server unreachable): {e}")
9393
return False
9494

9595
# ----------------------------
@@ -107,7 +107,7 @@ def get_offloading_layer():
107107
print("Error requesting layer:", r.status_code)
108108
return LAST_OFFLOADING_LAYER
109109
except requests.exceptions.RequestException as e:
110-
print(f" Cannot reach server: {e}")
110+
print(f"WARNING: Cannot reach server: {e}")
111111
print(" → Running all layers locally")
112112
return LAST_OFFLOADING_LAYER
113113

@@ -194,7 +194,7 @@ def send_inference_result(output_data, inference_times, layer_index, message_id)
194194
print("Output sent:", r.status_code)
195195
return True
196196
except requests.exceptions.RequestException as e:
197-
print(f" Cannot send result to server: {e}")
197+
print(f"WARNING: Cannot send result to server: {e}")
198198
print(" → Local inference completed, result not synchronized")
199199
return False
200200

@@ -211,7 +211,7 @@ def main():
211211
# Try to register, but continue even if it fails
212212
server_available = register_device()
213213
if not server_available:
214-
print("\n Server not available - Running in LOCAL-ONLY mode")
214+
print("\nWARNING: Server not available - Running in LOCAL-ONLY mode")
215215
print(" Client will continue and retry server connection on each request\n")
216216

217217
while True:
@@ -231,7 +231,7 @@ def main():
231231
# Try to send results (for variance tracking and algorithm updates)
232232
send_inference_result(output_data, inference_times, best_layer, message_id)
233233

234-
print(f"Inference complete (layers 0-{best_layer})\n")
234+
print(f"Inference complete (layers 0-{best_layer})\n")
235235

236236
main()
237237

server_client_light/client/http_config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ client:
33
device_id: device_01
44
delay_simulation:
55
device_computation:
6-
enabled: true
7-
std_dev: 0.5
8-
type: static
9-
value: 0.0001
6+
enabled: false
107
network:
118
enabled: true
12-
mean: 0.5
13-
std_dev: 1
9+
mean: 0.04
10+
std_dev: 0.02
1411
type: gaussian
1512
http:
1613
endpoints:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
client:
2+
client_id: null
3+
device_id: device_01
4+
delay_simulation:
5+
device_computation:
6+
enabled: true
7+
mean: 0.1
8+
std_dev: 0.1
9+
type: gaussian
10+
network:
11+
enabled: true
12+
type: static
13+
value: 0.02
14+
http:
15+
endpoints:
16+
device_inference_result: /api/device_inference_result
17+
device_input: /api/device_input
18+
offloading_layer: /api/offloading_layer
19+
registration: /api/registration
20+
server_host: 0.0.0.0
21+
server_port: 8000
22+
local_inference_mode:
23+
enabled: false
24+
probability: 0.0
25+
model:
26+
image_name: img.png
27+
input_height: 96
28+
input_width: 96
29+
last_offloading_layer: 58
30+
submodel_prefix: submodel
31+
tflite_subdir: tflite

0 commit comments

Comments
 (0)