(size_file)
| 173 | |
| 174 | |
| 175 | def load_serialized_sizes(size_file): |
| 176 | if not os.path.exists(size_file): |
| 177 | return {} |
| 178 | |
| 179 | pattern = re.compile( |
| 180 | r"^\|\s*([^|]+?)\s*\|\s*(\d+|n/a)\s*\|\s*(\d+|n/a)\s*\|\s*(\d+|n/a)\s*\|$", |
| 181 | re.IGNORECASE, |
| 182 | ) |
| 183 | sizes = {} |
| 184 | with open(size_file, "r", encoding="utf-8") as file: |
| 185 | for line in file: |
| 186 | match = pattern.match(line.strip()) |
| 187 | if not match: |
| 188 | continue |
| 189 | datatype, fory_size, protobuf_size, msgpack_size = match.groups() |
| 190 | if datatype == "Datatype": |
| 191 | continue |
| 192 | sizes[datatype] = { |
| 193 | "fory": parse_size_value(fory_size), |
| 194 | "protobuf": parse_size_value(protobuf_size), |
| 195 | "msgpack": parse_size_value(msgpack_size), |
| 196 | } |
| 197 | return sizes |
| 198 | |
| 199 | |
| 200 | def parse_size_value(value): |
no test coverage detected