Remove timestamp from trace JSON before benchmarking - oops!
authorChristopher Peplin <chris.peplin@rhubarbtech.com>
Sat, 5 Oct 2013 20:17:43 +0000 (16:17 -0400)
committerChristopher Peplin <chris.peplin@rhubarbtech.com>
Tue, 7 Jan 2014 18:18:09 +0000 (13:18 -0500)
The size savings is now about 35%, not 55%.

benchmark/proto/compare_sizes.py

index 5eee74c..f31a2e4 100755 (executable)
@@ -26,13 +26,15 @@ for trace_file in sys.argv[1:]:
         except ValueError:
             continue
 
+        del json_message['timestamp']
+
         message = openxc_pb2.VehicleMessage()
 
         if 'id' and 'data' in json_message:
             # rough approx. that CAN messages are 10 bytes - they could be less
             # but most of ours are full 64+11 bits
             total_raw_can_size += 10
-            total_raw_json_size += len(line)
+            total_raw_json_size += len(json.dumps(json_message))
             binary_message = openxc_pb2.RawMessage()
             binary_message.message_id = json_message['id']
             binary_message.data = int(json_message['data'], 0)
@@ -48,7 +50,7 @@ for trace_file in sys.argv[1:]:
                 message.translated_message.numerical_value = json_message['value']
             else:
                 message.translated_message.string_value = json_message['value']
-            total_translated_json_size += len(line)
+            total_translated_json_size += len(json.dumps(json_message))
             total_translated_binary_size += len(message.SerializeToString())