diff --git a/Stream/uav_proto_msg/protomsg/ComparePerformance.py b/Stream/uav_proto_msg/protomsg/ComparePerformance.py new file mode 100644 index 0000000..e12e6c0 --- /dev/null +++ b/Stream/uav_proto_msg/protomsg/ComparePerformance.py @@ -0,0 +1,64 @@ +import numpy as np +import matplotlib.pyplot as plt + + +fig = plt.figure(1) +plt.subplot(421) # 設定子圖 421 表示4*2 位置1 不想塞子圖就註解 +duration_info_message = 8 +duration_info_message_bin = 4 + +width=0.3 +x = ['set1'] +x1=np.arange(len(x)) #X 軸 (第一組) +y1=(8) #Y 軸1=duration_info_message +x2=[p + width for p in x1] #X 軸 (第二組) +y2=(4) #Y 軸2=duration_info_message_bin +plt.bar(x1, y1, label='Json', width=0.1) #繪製長條圖 +plt.bar(x2, y2, label='protobuf', width=0.1) #繪製長條圖 +plt.xticks([p + width/2 for p in x1], x) #設定 X 軸刻度標籤 +plt.legend() #顯示圖例 +plt.title('duration_info') #設定圖形標題 +# plt.xlabel('x label') #設定 X 軸標籤 +plt.ylabel('MB') #設定 Y 軸標籤 + + + +plt.subplot(422) +flight_info_message=85 +flight_info_message_bin=22 +width=0.3 +x = ['set2'] +x1=np.arange(len(x)) #X 軸 (第一組) +y1=(85) #Y 軸1=duration_info_message +x2=[p + width for p in x1] #X 軸 (第二組) +y2=(22) #Y 軸2=duration_info_message_bin +plt.bar(x1, y1, label='Json', width=0.1) #繪製長條圖 +plt.bar(x2, y2, label='protobuf', width=0.1) #繪製長條圖 +plt.xticks([p + width/2 for p in x1], x) #設定 X 軸刻度標籤 +plt.legend() #顯示圖例 +plt.title('flight_info') #設定圖形標題 +# plt.xlabel('x label') #設定 X 軸標籤 +plt.ylabel('MB') #設定 Y 軸標籤 + + + +fig = plt.figure(2) + +json=404 +serial=97 +width=0.3 +x = ['set'] +x1=np.arange(len(x)) #X 軸 (第一組) +y1=(404) #Y 軸1=duration_info_message +x2=[p + width for p in x1] #X 軸 (第二組) +y2=(97) #Y 軸2=duration_info_message_bin +plt.bar(x1, y1, label='Json', width=0.1) #繪製長條圖 +plt.bar(x2, y2, label='protobuf', width=0.1) #繪製長條圖 +plt.xticks([p + width/2 for p in x1], x) #設定 X 軸刻度標籤 +plt.legend() #顯示圖例 +plt.title('flight_info') #設定圖形標題 +# plt.xlabel('x label') #設定 X 軸標籤 +plt.ylabel('MB') #設定 Y 軸標籤 + + +plt.show() \ No newline at end of file diff --git a/Stream/uav_proto_msg/protomsg/__pycache__/protoMsg.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/__pycache__/protoMsg.cpython-310.pyc index a572040..505eed5 100644 Binary files a/Stream/uav_proto_msg/protomsg/__pycache__/protoMsg.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/__pycache__/protoMsg.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/__pycache__/protoMsg.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/__pycache__/protoMsg.cpython-39.pyc new file mode 100644 index 0000000..c72bbd6 Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/__pycache__/protoMsg.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/duration_pb2.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/duration_pb2.cpython-310.pyc index 70a4164..2d4371c 100644 Binary files a/Stream/uav_proto_msg/protomsg/proto/__pycache__/duration_pb2.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/duration_pb2.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/duration_pb2.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/duration_pb2.cpython-39.pyc new file mode 100644 index 0000000..0053d3a Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/duration_pb2.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flight_information_pb2.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flight_information_pb2.cpython-310.pyc index b4b562d..f1235e9 100644 Binary files a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flight_information_pb2.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flight_information_pb2.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flight_information_pb2.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flight_information_pb2.cpython-39.pyc new file mode 100644 index 0000000..7fafdf7 Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flight_information_pb2.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flyformatioln_pb2.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flyformatioln_pb2.cpython-310.pyc index 3b26df4..116c999 100644 Binary files a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flyformatioln_pb2.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flyformatioln_pb2.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flyformatioln_pb2.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flyformatioln_pb2.cpython-39.pyc new file mode 100644 index 0000000..76fd1ac Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flyformatioln_pb2.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flymode_pb2.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flymode_pb2.cpython-310.pyc index 954d35c..24a1ecc 100644 Binary files a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flymode_pb2.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flymode_pb2.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/flymode_pb2.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flymode_pb2.cpython-39.pyc new file mode 100644 index 0000000..9f1e80d Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/flymode_pb2.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/imu_pb2.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/imu_pb2.cpython-310.pyc index a03d27d..b9b0e27 100644 Binary files a/Stream/uav_proto_msg/protomsg/proto/__pycache__/imu_pb2.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/imu_pb2.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/imu_pb2.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/imu_pb2.cpython-39.pyc new file mode 100644 index 0000000..64a99e8 Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/imu_pb2.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/odom_pb2.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/odom_pb2.cpython-310.pyc index 0f1b1dc..a53ba0a 100644 Binary files a/Stream/uav_proto_msg/protomsg/proto/__pycache__/odom_pb2.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/odom_pb2.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/odom_pb2.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/odom_pb2.cpython-39.pyc new file mode 100644 index 0000000..edadc0d Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/odom_pb2.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/timestamp_pb2.cpython-310.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/timestamp_pb2.cpython-310.pyc index ea4569f..0e59f46 100644 Binary files a/Stream/uav_proto_msg/protomsg/proto/__pycache__/timestamp_pb2.cpython-310.pyc and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/timestamp_pb2.cpython-310.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/proto/__pycache__/timestamp_pb2.cpython-39.pyc b/Stream/uav_proto_msg/protomsg/proto/__pycache__/timestamp_pb2.cpython-39.pyc new file mode 100644 index 0000000..c21c486 Binary files /dev/null and b/Stream/uav_proto_msg/protomsg/proto/__pycache__/timestamp_pb2.cpython-39.pyc differ diff --git a/Stream/uav_proto_msg/protomsg/size/timestamp_info_message b/Stream/uav_proto_msg/protomsg/size/timestamp_info_message index e899c71..068797d 100644 --- a/Stream/uav_proto_msg/protomsg/size/timestamp_info_message +++ b/Stream/uav_proto_msg/protomsg/size/timestamp_info_message @@ -1 +1 @@ -"2022-12-04T15:50:18.050641Z" \ No newline at end of file +"2022-12-08T07:22:43.602554Z" \ No newline at end of file diff --git a/Stream/uav_proto_msg/protomsg/size/timestamp_info_message.bin b/Stream/uav_proto_msg/protomsg/size/timestamp_info_message.bin index a454dff..b85b6da 100644 --- a/Stream/uav_proto_msg/protomsg/size/timestamp_info_message.bin +++ b/Stream/uav_proto_msg/protomsg/size/timestamp_info_message.bin @@ -1 +1 @@ - \ No newline at end of file +áƜ𜔟 \ No newline at end of file diff --git a/Stream/uav_proto_msg/protomsg/size_test.py b/Stream/uav_proto_msg/protomsg/size_test.py index 5f76587..19a6813 100644 --- a/Stream/uav_proto_msg/protomsg/size_test.py +++ b/Stream/uav_proto_msg/protomsg/size_test.py @@ -10,42 +10,45 @@ def file(message, path, json=False, serial=False): 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) +def proto_msg(): + 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] + for message in serial: + file(message, serial_name[serial.index(message)], serial=True) + +def json_msg(): + 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] + + for message in js: + file(message, serial_name[js.index(message)], json=True) + +if __name__ == '__main__': + serial_name = ["flight_info_message", "fly_format_message", "imu_info_message", "odom_info_message", "flymode_info_message", "duration_info_message", "timestamp_info_message"] + proto_msg() + json_msg() + serlizl_size = 0 + json_size = 0 + size = {"flight_info_message":{"Json":None, "Proto":None}} + 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)