-print("Binary encoding is %f%% smaller than JSON for raw messages" % (
- 100 - (total_raw_binary_size / total_raw_json_size * 100)))
-print("Binary encoding is %f%% smaller than JSON for translated messages" % (
- 100 - (total_translated_binary_size / total_translated_json_size * 100)))
+if total_raw_can_size > 0:
+ print("Binary encoding adds %f%% overhead to raw CAN messages" % (
+ total_raw_binary_size / total_raw_can_size * 100 - 100))
+ print("JSON encoding adds %f%% overhead to raw CAN messages" % (
+ total_raw_json_size / total_raw_can_size * 100 - 100))
+if total_raw_json_size > 0:
+ print("Binary encoding is %f%% smaller than JSON for raw messages" % (
+ 100 - (total_raw_binary_size / total_raw_json_size * 100)))
+if total_translated_json_size > 0:
+ print("Binary encoding is %f%% smaller than JSON for translated messages" % (
+ 100 - (total_translated_binary_size / total_translated_json_size * 100)))