summaryrefslogtreecommitdiffstats
path: root/benchmark/proto
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2013-10-23 09:02:33 -0400
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-07 13:18:10 -0500
commitda1d41840879bc75a9df06972e1ec191bbfd3691 (patch)
treed25f57f7872963396f83ca0f10f2aa4c73b29d04 /benchmark/proto
parent4904749890b1f2570f9197da99a07a76471e8400 (diff)
Switch back to many subtypes for binary messages.
Some protobuf libraries don't support checking if a field exists (they always return a default value), so although this style has more code it is easier to support.
Diffstat (limited to 'benchmark/proto')
-rwxr-xr-xbenchmark/proto/compare_sizes.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/benchmark/proto/compare_sizes.py b/benchmark/proto/compare_sizes.py
index e4ae6691..1fb96030 100755
--- a/benchmark/proto/compare_sizes.py
+++ b/benchmark/proto/compare_sizes.py
@@ -40,14 +40,35 @@ for trace_file in sys.argv[1:]:
message.raw_message.data = int(json_message['data'], 0)
total_raw_binary_size += len(message.SerializeToString())
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']
+ if 'event' in json_message:
+ if isinstance(json_message['event'], bool):
+ message.type = openxc_pb2.VehicleMessage.EVENTED_BOOL
+ message.evented_boolean_message.name = json_message['name']
+ message.evented_boolean_message.value = json_message['value']
+ message.evented_boolean_message.event = json_message['event']
+ elif isinstance(json_message['event'], numbers.Number):
+ message.type = openxc_pb2.VehicleMessage.EVENTED_NUM
+ message.evented_numeric_message.name = json_message['name']
+ message.evented_numeric_message.value = json_message['value']
+ message.evented_numeric_message.event = json_message['event']
+ else:
+ message.type = openxc_pb2.VehicleMessage.EVENTED_STRING
+ message.evented_string_message.name = json_message['name']
+ message.evented_string_message.value = json_message['value']
+ message.evented_numeric_message.event = json_message['event']
else:
- message.translated_message.string_value = json_message['value']
+ if isinstance(json_message['value'], bool):
+ message.type = openxc_pb2.VehicleMessage.BOOL
+ message.boolean_message.name = json_message['name']
+ message.boolean_message.value = json_message['value']
+ elif isinstance(json_message['value'], numbers.Number):
+ message.type = openxc_pb2.VehicleMessage.NUM
+ message.numeric_message.name = json_message['name']
+ message.numeric_message.value = json_message['value']
+ else:
+ message.type = openxc_pb2.VehicleMessage.STRING
+ message.string_message.name = json_message['name']
+ message.string_message.value = json_message['value']
total_translated_json_size += len(json.dumps(json_message))
total_translated_binary_size += len(message.SerializeToString())