Run *query* with each params tuple, cycling through params_list for *iterations* total executions. Return per-query times in seconds.
(
conn: sqlite3.Connection,
query: str,
params_list: list[tuple],
iterations: int,
)
| 85 | |
| 86 | |
| 87 | def bench_query( |
| 88 | conn: sqlite3.Connection, |
| 89 | query: str, |
| 90 | params_list: list[tuple], |
| 91 | iterations: int, |
| 92 | ) -> list[float]: |
| 93 | """Run *query* with each params tuple, cycling through params_list for |
| 94 | *iterations* total executions. Return per-query times in seconds.""" |
| 95 | times: list[float] = [] |
| 96 | for i in range(iterations): |
| 97 | params = params_list[i % len(params_list)] |
| 98 | start = time.perf_counter() |
| 99 | conn.execute(query, params).fetchall() |
| 100 | elapsed = time.perf_counter() - start |
| 101 | times.append(elapsed) |
| 102 | return times |
| 103 | |
| 104 | |
| 105 | def bench_in_query( |