MCPcopy
hub / github.com/idank/explainshell / bench_in_query

Function bench_in_query

tools/bench_src_index.py:105–119  ·  view source on GitHub ↗

Benchmark the IN (...) query used by _discover_manpage_suggestions.

(
    conn: sqlite3.Connection,
    src_groups: list[list[str]],
    iterations: int,
)

Source from the content-addressed store, hash-verified

103
104
105def bench_in_query(
106 conn: sqlite3.Connection,
107 src_groups: list[list[str]],
108 iterations: int,
109) -> list[float]:
110 """Benchmark the IN (...) query used by _discover_manpage_suggestions."""
111 times: list[float] = []
112 for i in range(iterations):
113 group = src_groups[i % len(src_groups)]
114 query = build_query_in(len(group))
115 start = time.perf_counter()
116 conn.execute(query, group).fetchall()
117 elapsed = time.perf_counter() - start
118 times.append(elapsed)
119 return times
120
121
122def report(label: str, times: list[float]) -> dict[str, float]:

Callers 1

run_suiteFunction · 0.85

Calls 2

rangeFunction · 0.85
build_query_inFunction · 0.85

Tested by

no test coverage detected