diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-10-23 09:02:33 -0400 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-07 13:18:10 -0500 |
commit | da1d41840879bc75a9df06972e1ec191bbfd3691 (patch) | |
tree | d25f57f7872963396f83ca0f10f2aa4c73b29d04 /benchmark | |
parent | 4904749890b1f2570f9197da99a07a76471e8400 (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')
-rwxr-xr-x | benchmark/proto/compare_sizes.py | 35 |
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()) |