compare size with json and proto
parent
79ec971bfa
commit
2a39731eb8
@ -0,0 +1,51 @@
|
||||
import os
|
||||
from protoMsg import protoMsgWrapper
|
||||
|
||||
def file(message, path, json=False, serial=False):
|
||||
path = "size/" + path
|
||||
if serial:
|
||||
with open(path+".bin", "wb") as f:
|
||||
f.write(message)
|
||||
elif json:
|
||||
with open(path, "w") as f:
|
||||
f.write(message)
|
||||
|
||||
|
||||
flight_info_message = protoMsgWrapper.flight_information(serialized = True)
|
||||
fly_format_message = protoMsgWrapper.fly_formation(serialized = True)
|
||||
imu_info_message = protoMsgWrapper.imu_information(serialized = True)
|
||||
odom_info_message = protoMsgWrapper.odom_information(serialized = True)
|
||||
flymode_info_message = protoMsgWrapper.flymode_information(serialized = True)
|
||||
duration_info_message = protoMsgWrapper.duration_information(serialized = True)
|
||||
timestamp_info_message = protoMsgWrapper.timestamp_information(serialized = True)
|
||||
serial = [flight_info_message, fly_format_message, imu_info_message, odom_info_message, flymode_info_message, duration_info_message, timestamp_info_message]
|
||||
serial_name = ["flight_info_message", "fly_format_message", "imu_info_message", "odom_info_message", "flymode_info_message", "duration_info_message", "timestamp_info_message"]
|
||||
for message in serial:
|
||||
file(message, serial_name[serial.index(message)], serial=True)
|
||||
|
||||
flight_info_message = protoMsgWrapper.flight_information(tojson = True)
|
||||
fly_format_message = protoMsgWrapper.fly_formation(tojson = True)
|
||||
imu_info_message = protoMsgWrapper.imu_information(tojson = True)
|
||||
odom_info_message = protoMsgWrapper.odom_information(tojson = True)
|
||||
flymode_info_message = protoMsgWrapper.flymode_information(tojson = True)
|
||||
duration_info_message = protoMsgWrapper.duration_information(tojson = True)
|
||||
timestamp_info_message = protoMsgWrapper.timestamp_information(tojson = True)
|
||||
js = [flight_info_message, fly_format_message, imu_info_message, odom_info_message, flymode_info_message, duration_info_message, timestamp_info_message]
|
||||
js_name = ["flight_info_message", "fly_format_message", "imu_info_message", "odom_info_message", "flymode_info_message", "duration_info_message", "timestamp_info_message"]
|
||||
for message in js:
|
||||
file(message, js_name[js.index(message)], json=True)
|
||||
|
||||
|
||||
|
||||
serlizl_size = 0
|
||||
json_size = 0
|
||||
files = sorted(os.listdir("size"))
|
||||
for file in files:
|
||||
size = os.path.getsize("size/"+file)
|
||||
print(file, size)
|
||||
if file.endswith(".bin"):
|
||||
serlizl_size += size
|
||||
else:
|
||||
json_size += size
|
||||
|
||||
print("json - serial = ", json_size - serlizl_size)
|
||||
Loading…
Reference in New Issue