Skip to content
Merged
2 changes: 1 addition & 1 deletion _prepare_dev_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Script for building test DAWGs.
"""

import struct

import dawg
Expand Down Expand Up @@ -40,7 +41,6 @@ def create_int_completion_dawg():


def build_test_data() -> None:

dawg.CompletionDAWG(["f", "bar", "foo", "foobar"]).save("dev_data/small/completion.dawg")
dawg.CompletionDAWG([]).save("dev_data/small/completion-empty.dawg")

Expand Down
9 changes: 4 additions & 5 deletions bench/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def load_int_dawg():


def benchmark() -> None:

tests = [
("__getitem__ (hits)", "for word in WORDS100k: data[word]", "M ops/sec", 0.1, 3),
("get() (hits)", "for word in WORDS100k: data.get(word)", "M ops/sec", 0.1, 3),
Expand Down Expand Up @@ -109,14 +108,14 @@ def benchmark() -> None:

# DAWG-specific benchmarks
for struct_name, setup in structures[1:]:
_bench_data = [
_bench_data_pairs = [
("hits", "WORDS100k"),
("mixed", "MIXED_WORDS100k"),
("misses", "NON_WORDS100k"),
]

for meth in ["prefixes"]:
for name, data in _bench_data:
for name, data in _bench_data_pairs:
bench(
f"{struct_name}.{meth} ({name})",
timeit.Timer(
Expand All @@ -126,14 +125,14 @@ def benchmark() -> None:
runs=3,
)

_bench_data = [
_bench_data_triples = [
("xxx", "avg_len(res)==415", "PREFIXES_3_1k"),
("xxxxx", "avg_len(res)==17", "PREFIXES_5_1k"),
("xxxxxxxx", "avg_len(res)==3", "PREFIXES_8_1k"),
("xxxxx..xx", "avg_len(res)==1.4", "PREFIXES_15_1k"),
("xxx", "NON_EXISTING", "NON_WORDS_1k"),
]
for xxx, avg, data in _bench_data:
for xxx, avg, data in _bench_data_triples:
for meth in ["keys", "items"]:
bench(
f'{struct_name}.{meth}(prefix="{xxx}"), {avg}',
Expand Down
Loading