From 6065eaaa207221c4d31464d0a1df73cfa719a86d Mon Sep 17 00:00:00 2001 From: RangeOfGlitching <58881058+RangeOfGlitching@users.noreply.github.com> Date: Mon, 5 Dec 2022 00:01:07 +0800 Subject: [PATCH] Delete timeit_test.py --- Stream/uav_proto_msg/timeit_test.py | 56 ----------------------------- 1 file changed, 56 deletions(-) delete mode 100644 Stream/uav_proto_msg/timeit_test.py diff --git a/Stream/uav_proto_msg/timeit_test.py b/Stream/uav_proto_msg/timeit_test.py deleted file mode 100644 index 86d2b3d..0000000 --- a/Stream/uav_proto_msg/timeit_test.py +++ /dev/null @@ -1,56 +0,0 @@ -import proto.flyformatioln_pb2 as flyformatioln_pb2 -import proto.flight_information_pb2 as flight_information_pb2 -import google.protobuf.json_format as json_format -import timeit -import orjson -import json -a = '{"gps": {"LAT": 34123.125, "LON": 23423.123, "ALT": 12123.123}, "heading": 155.12215}' -data ={} - -flight_information_msg = flight_information_pb2.flight_information_message() -flight_information_msg.gps.LAT = 34123.1231515 -flight_information_msg.gps.LON = 23423.1231515 -flight_information_msg.gps.ALT = 12123.1231515 -flight_information_msg.heading = 155.12215 -proto_deserialize_msg = flight_information_msg.SerializeToString() - - - -def proto_serialize(): - flight_information_msg = flight_information_pb2.flight_information_message() - flight_information_msg.gps.LAT = 34123.1231515 - flight_information_msg.gps.LON = 23423.1231515 - flight_information_msg.gps.ALT = 12123.1231515 - flight_information_msg.heading = 155.12215 - proto_deserialize_msg = flight_information_msg.SerializeToString() - - -def proto_deserialize(proto): - proto_msg = flight_information_msg.FromString(proto) - # js = json_format.MessageToJson(proto_msg, indent=None, preserving_proto_field_name=True) - -def json_serialize(lib): - lat = 34123.1231515 - lon = 23423.1231515 - alt = 12123.1231515 - heading = 155.12215 - dataGpsUpdate = {"gps": {"lat": lat, "lon": lon, "ALT": alt}, "heading":heading} - data.update(dataGpsUpdate) - js = lib.dumps(data).decode("utf-8") - # print(js) -def json_deserialize(lib): - js = lib.loads(a) - # print(js) - - - - -proto_serialize_time = timeit.timeit(lambda: proto_serialize(), number = 150000) -proto_deserialize_time = timeit.timeit(lambda: proto_deserialize(proto_deserialize_msg), number = 150000) -json_serialize_time = timeit.timeit(lambda: json_serialize(orjson), number = 150000) -json_deserialize_time = timeit.timeit(lambda: json_deserialize(orjson), number = 150000) -print(f"proto_serialize_time: {proto_serialize_time}") -print(f"json_serialize_time: {json_serialize_time}") -print() -print(f"proto_deserialize_time: {proto_deserialize_time}") -print(f"json_deserialize_time: {json_deserialize_time}") \ No newline at end of file