speed up log writing

old-commit-hash: f728edfd0354f78cf8db99cf801f826fe22712f5
This commit is contained in:
Willem Melching
2021-02-17 12:06:55 +01:00
parent 05eb44115e
commit d8da956f0d
@@ -16,11 +16,11 @@ from tools.lib.logreader import LogReader
EPSILON = sys.float_info.epsilon
def save_log(dest, log_msgs):
dat = b""
for msg in tqdm(log_msgs):
dat += msg.as_builder().to_bytes()
dat = bz2.compress(dat)
def save_log(dest, log_msgs, compress=True):
dat = b"".join([msg.as_builder().to_bytes() for msg in tqdm(log_msgs)])
if compress:
dat = bz2.compress(dat)
with open(dest, "wb") as f:
f.write(dat)