diff options
Diffstat (limited to 'benchmark')
-rwxr-xr-x | benchmark/proto/compare_sizes.py | 22 | ||||
-rw-r--r-- | benchmark/proto/openxc.proto | 11 |
2 files changed, 26 insertions, 7 deletions
diff --git a/benchmark/proto/compare_sizes.py b/benchmark/proto/compare_sizes.py index b6936df6..192716f4 100755 --- a/benchmark/proto/compare_sizes.py +++ b/benchmark/proto/compare_sizes.py @@ -26,6 +26,8 @@ for trace_file in sys.argv[1:]: except ValueError: continue + 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 @@ -34,18 +36,24 @@ for trace_file in sys.argv[1:]: binary_message = openxc_pb2.RawMessage() binary_message.message_id = json_message['id'] binary_message.data = int(json_message['data'], 0) - total_raw_binary_size += len(binary_message.SerializeToString()) + message.type = openxc_pb2.VehicleMessage.RAW + message.raw_message = binary_message + total_raw_binary_size += len(message.SerializeToString()) else: if isinstance(json_message['value'], bool): - binary_message = openxc_pb2.TranslatedBooleanMessage() + 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): - binary_message = openxc_pb2.TranslatedNumericMessage() + message.type = openxc_pb2.VehicleMessage.NUM + message.numerical_message.name = json_message['name'] + message.numerical_message.value = json_message['value'] else: - binary_message = openxc_pb2.TranslatedStringMessage() - binary_message.name = json_message['name'] - binary_message.value = json_message['value'] + 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(line) - total_translated_binary_size += len(binary_message.SerializeToString()) + total_translated_binary_size += len(message.SerializeToString()) print("For the %d trace files given..." % len(sys.argv[1:])) diff --git a/benchmark/proto/openxc.proto b/benchmark/proto/openxc.proto index 0e39bb6c..1917b0bd 100644 --- a/benchmark/proto/openxc.proto +++ b/benchmark/proto/openxc.proto @@ -1,5 +1,16 @@ package openxc; +message VehicleMessage { + enum Type { RAW = 1; STRING = 2; NUM = 3; BOOL = 4; } + + optional Type type = 1; + + optional RawMessage raw_message = 2; + optional TranslatedStringMessage string_message = 3; + optional TranslatedNumericMessage numerical_message = 4; + optional TranslatedBooleanMessage boolean_message = 5; +} + message RawMessage { optional uint32 message_id = 1; optional double data = 2; |