forked from quickwit-oss/search-benchmark-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regression.py
35 lines (29 loc) · 947 Bytes
/
regression.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json
reference = "tantivy-0.8"
all = json.load(open("results.json"))
def query_count(query_bench):
c = {}
for q in query_bench:
c[q["query"]] = q["count"]
return c
def compare(ref_count, engine_count):
diffs = []
assert len(ref_count) == len(engine_count)
for q in ref_count:
if ref_count[q] != engine_count[q]:
diffs.append((q, ref_count[q], engine_count[q]))
return diffs
for (metric, engine_bench) in all.items():
print "\n\n=======\nMetric", metric
ref_count = query_count(engine_bench[reference])
# print ref_count
for (engine, query_bench) in engine_bench.items():
if not "tantivy" in engine:
print "skipping", engine
continue
print engine
engine_count = query_count(query_bench)
diff = compare(ref_count, engine_count)
if diff:
print "Engine", engine
print diff