tests/sha256line.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sun, 14 Apr 2024 02:40:15 +0200
changeset 51590 a6bdd2e6f7cb
parent 51361 fa4c4fa232d6
permissions -rwxr-xr-x
perf: run the gc before each run The python garbage collector is a large source of performance troubles, we run it right before the timed section to reduce the change for the gc to add noise to the benchmark.

#!/usr/bin/env python3
#
# A tool to help producing large and poorly compressible files
#
# Usage:
#   $TESTDIR/seq.py 1000 | $TESTDIR/sha256line.py > my-file.txt


import hashlib
import sys


for line in sys.stdin:
    print(hashlib.sha256(line.encode('utf8')).hexdigest())