#!/usr/bin/env python3 import sys import time import zst_zstd import zst_zstandard import zst_pyzstd def speed_test(module): """Check the performance of 'module'.""" with open('/etc/protocols', 'rb') as file_: protocols = file_.read() data = protocols * 1024 time0 = time.time() for i in range(1000): compressed_data = module.compress(data) uncompressed_data = module.decompress(compressed_data) assert uncompressed_data == data time1 = time.time() print(module, time1 - time0) def main(): """Run the tests, once for each module.""" for module in [zst_zstd, zst_zstandard, zst_pyzstd]: speed_test(module) if __name__ == '__main__': main()