#!/usr/bin/env python3 """General-purpose compressor baselines for tick files (see README.md). usage: baselines.py ZSTD_BINARY TMP_DIR file.ticks:digits ... Prints bytes/tick for xz -9e and zstd -19 --long on raw24 the raw 24-byte records, delta-rows12 per-tick (dt, dbid, dask) as 3 x int32, delta-varint-cols columnar zig-zag varints of dt, dbid, dask. """ import struct, sys, subprocess, os def varint(x, out): while True: b = x & 0x7f; x >>= 7 if x: out.append(b | 0x80) else: out.append(b); return def zz(x): return (x << 1) ^ (x >> 63) if x < 0 else x << 1 ZSTD=sys.argv[1] tmp=sys.argv[2] for p, dg in [(a.split(':')[0], int(a.split(':')[1])) for a in sys.argv[3:]]: d = open(p, 'rb').read(); n = len(d)//24; s = 10**dg T = [struct.unpack_from('