summaryrefslogtreecommitdiffstats
path: root/benchmark
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2013-10-24 10:09:30 -0400
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-07 13:18:10 -0500
commitf8ea5374f584310fbd7521b41385a71eb7c613d3 (patch)
treef8584d229fcbf76d16c665e5151af2e796fec4cb /benchmark
parent25dcef2e59fed31f0bba291a9a08f5021e371cf8 (diff)
Minimize the number of separate protobuf types.
Diffstat (limited to 'benchmark')
-rwxr-xr-xbenchmark/proto/compare_sizes.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/benchmark/proto/compare_sizes.py b/benchmark/proto/compare_sizes.py
index e4ae6691..0ed445fd 100755
--- a/benchmark/proto/compare_sizes.py
+++ b/benchmark/proto/compare_sizes.py
@@ -42,12 +42,27 @@ for trace_file in sys.argv[1:]:
else:
message.type = openxc_pb2.VehicleMessage.TRANSLATED
message.translated_message.name = json_message['name']
- if isinstance(json_message['value'], bool):
- message.translated_message.boolean_value = json_message['value']
- elif isinstance(json_message['value'], numbers.Number):
- message.translated_message.numerical_value = json_message['value']
- else:
+ if 'event' in json_message:
message.translated_message.string_value = json_message['value']
+ if isinstance(json_message['event'], bool):
+ message.translated_message.type = openxc_pb2.TranslatedMessage.EVENTED_BOOL
+ message.translated_message.boolean_event = json_message['event']
+ elif isinstance(json_message['event'], numbers.Number):
+ message.translated_message.type = openxc_pb2.TranslatedMessage.EVENTED_NUM
+ message.translated_message.numeric_value = json_message['event']
+ else:
+ message.translated_message.type = openxc_pb2.TranslatedMessage.EVENTED_STRING
+ message.translated_message.string_value = json_message['event']
+ else:
+ if isinstance(json_message['value'], bool):
+ message.translated_message.type = openxc_pb2.TranslatedMessage.BOOL
+ message.translated_message.boolean_value = json_message['value']
+ elif isinstance(json_message['value'], numbers.Number):
+ message.translated_message.type = openxc_pb2.TranslatedMessage.NUM
+ message.translated_message.numeric_value = json_message['value']
+ else:
+ message.translated_message.type = openxc_pb2.TranslatedMessage.STRING
+ message.translated_message.string_value = json_message['value']
total_translated_json_size += len(json.dumps(json_message))
total_translated_binary_size += len(message.SerializeToString())