Changeset View
Changeset View
Standalone View
Standalone View
swh/perfecthash/tests/test_hash.py
- This file was added.
import os | |||||
from swh.perfecthash import Shard | |||||
def test_all(tmpdir): | |||||
f = f"{tmpdir}/shard" | |||||
open(f, "w").close() | |||||
os.truncate(f, 10 * 1024 * 1024) | |||||
s = Shard(f).create(2) | |||||
keyA = b"A" * 32 | |||||
objectA = b"AAAA" | |||||
s.write(keyA, objectA) | |||||
keyB = b"B" * 32 | |||||
objectB = b"BBBB" | |||||
s.write(keyB, objectB) | |||||
s.save() | |||||
del s | |||||
s = Shard(f).load() | |||||
assert s.lookup(keyA) == objectA | |||||
assert s.lookup(keyB) == objectB | |||||
del s | |||||
ardumont: I don't get that comparison, where does the 5 ratio come from?
| |||||
Done Inline ActionsIt seems to be a ratio that satisfies what's explained in the readme earlier (both for large and small files) ardumont: It seems to be a ratio that satisfies what's explained in the readme earlier (both for large… | |||||
Done Inline ActionsThe idea is to guard against massive performance regressions. When and if creating a shard is five times slower than copying a file... there is cause for concern. It comes from my head and has no real justification other than: this would be bad. dachary: The idea is to guard against massive performance regressions. When and if creating a shard is… | |||||
Done Inline ActionsAs a comment maybe something like: # According to the docs/benchmarks.rst analysis, the duration is below 5 times the baseline time # This assertion is here to ensure we do not not regress in the future... or something In any case, thanks for the explanation! ardumont: As a comment maybe something like:
```
# According to the docs/benchmarks.rst analysis, the… |
I don't get that comparison, where does the 5 ratio come from?