-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Labels
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Comparing to another implementation of crc32c shows a pretty big operation per second gap.
related to aiortc/aiortc#528
import time
import crc32c
import google_crc32c
blob = bytes(1200)
iterations = 10000000
start = time.time()
for i in range(iterations):
crc32c.crc32c(blob)
elapsed = time.time() - start
print("crc32c %d op/s" % (iterations / elapsed))
start = time.time()
for i in range(iterations):
google_crc32c.value(blob)
elapsed = time.time() - start
print("google_crc32c %d op/s" % (iterations / elapsed))
❯ python -m venv venv; source venv/bin/activate
❯ code test_crc32c_v_google_crc32c.py
❯ pip install google-crc32c
Collecting google-crc32c
Downloading google_crc32c-1.1.2-cp39-cp39-macosx_10_14_x86_64.whl (27 kB)
Collecting cffi>=1.0.0
Using cached cffi-1.14.5-cp39-cp39-macosx_10_9_x86_64.whl (177 kB)
Collecting pycparser
Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Installing collected packages: pycparser, cffi, google-crc32c
Successfully installed cffi-1.14.5 google-crc32c-1.1.2 pycparser-2.20
❯ pip install crc32c
Collecting crc32c
Downloading crc32c-2.2-cp39-cp39-macosx_10_9_x86_64.whl (28 kB)
Installing collected packages: crc32c
Successfully installed crc32c-2.2
❯ python test_crc32c_v_google_crc32c.py
crc32c 3435773 op/s
google_crc32c 946106 op/s
❯ python test_crc32c_v_google_crc32c.py
crc32c 3785717 op/s
google_crc32c 899703 op/s
Metadata
Metadata
Labels
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.