Return three lists of src values for benchmarking. - single_dst: src values that map to exactly 1 destination (common case) - multi_dst: src values that map to >1 destination - subcommand: src values containing a space (e.g. 'git commit')
(
conn: sqlite3.Connection, n: int
)
| 50 | |
| 51 | |
| 52 | def collect_sample_srcs( |
| 53 | conn: sqlite3.Connection, n: int |
| 54 | ) -> tuple[list[str], list[str], list[str]]: |
| 55 | """Return three lists of src values for benchmarking. |
| 56 | |
| 57 | - single_dst: src values that map to exactly 1 destination (common case) |
| 58 | - multi_dst: src values that map to >1 destination |
| 59 | - subcommand: src values containing a space (e.g. 'git commit') |
| 60 | """ |
| 61 | single = [ |
| 62 | r[0] |
| 63 | for r in conn.execute( |
| 64 | "SELECT src FROM mappings GROUP BY src HAVING COUNT(*) = 1 " |
| 65 | "ORDER BY RANDOM() LIMIT ?", |
| 66 | (n,), |
| 67 | ).fetchall() |
| 68 | ] |
| 69 | multi = [ |
| 70 | r[0] |
| 71 | for r in conn.execute( |
| 72 | "SELECT src FROM mappings GROUP BY src HAVING COUNT(*) > 1 " |
| 73 | "ORDER BY RANDOM() LIMIT ?", |
| 74 | (n,), |
| 75 | ).fetchall() |
| 76 | ] |
| 77 | subcmd = [ |
| 78 | r[0] |
| 79 | for r in conn.execute( |
| 80 | "SELECT src FROM mappings WHERE src LIKE '% %' ORDER BY RANDOM() LIMIT ?", |
| 81 | (n,), |
| 82 | ).fetchall() |
| 83 | ] |
| 84 | return single, multi, subcmd |
| 85 | |
| 86 | |
| 87 | def bench_query( |