| Server IP : 103.161.17.216 / Your IP : 216.73.216.59 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /snap/lxd/current/lib/python3/dist-packages/crc32c/ |
Upload File : |
import argparse
import time
import typing
from ._crc32c import crc32c
DEFAULT_SIZE = 100 * 1024 * 1024
DEFAULT_ITERATIONS = 10
def run(size: int, iterations: int) -> typing.Tuple[float, int]:
data = b" " * size
start = time.monotonic()
evaluations = 0
while True:
evaluations += iterations
[crc32c(data) for _ in range(iterations)]
duration = time.monotonic() - start
if duration > 0:
break
return duration, evaluations
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
"-s",
"--size",
type=int,
help=f"Amount of bytes to checksum, defaults to {DEFAULT_SIZE}",
default=DEFAULT_SIZE,
)
parser.add_argument(
"-i",
"--iterations",
type=int,
help=f"Number of times the checksum should we run over the data, defaults to {DEFAULT_ITERATIONS}",
default=DEFAULT_ITERATIONS,
)
options = parser.parse_args()
duration, evaluations = run(options.size, options.iterations)
size_mb = options.size / 1024 / 1024
avg_speed_gbs = size_mb / 1024 * evaluations / duration
print(
f"crc32c ran at {avg_speed_gbs:.3f} [GB/s] when checksuming {size_mb:.3f} [MB] {evaluations} times"
)
if __name__ == "__main__":
main()