Skip to content

Commit 67cdf19

Browse files
[Autoloop: perf-comparison] Iteration 411: add readTable benchmark
Run: https://github.com/githubnext/tsb/actions/runs/29710840981 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1d41558 commit 67cdf19

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Benchmark: read_table — parse a 100k-row tab-separated file"""
2+
import json, time
3+
import pandas as pd
4+
5+
ROWS = 100_000
6+
WARMUP = 2
7+
ITERATIONS = 5
8+
9+
# Build TSV file
10+
tmp_path = "/tmp/gh-aw/agent/bench_read_table.tsv"
11+
with open(tmp_path, "w") as f:
12+
f.write("id\tvalue\tlabel\n")
13+
for i in range(ROWS):
14+
f.write(f"{i}\t{i * 1.1:.4f}\tcat_{i % 50}\n")
15+
16+
for _ in range(WARMUP):
17+
pd.read_table(tmp_path)
18+
19+
start = time.perf_counter()
20+
for _ in range(ITERATIONS):
21+
pd.read_table(tmp_path)
22+
total = (time.perf_counter() - start) * 1000
23+
24+
print(json.dumps({
25+
"function": "read_table",
26+
"mean_ms": total / ITERATIONS,
27+
"iterations": ITERATIONS,
28+
"total_ms": total,
29+
}))

benchmarks/tsb/bench_read_table.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Benchmark: readTable — parse a 100k-row tab-separated string
3+
*/
4+
import { readTable } from "../../src/index.js";
5+
6+
const ROWS = 100_000;
7+
const WARMUP = 2;
8+
const ITERATIONS = 5;
9+
10+
// Build TSV string (tab-separated)
11+
const lines = ["id\tvalue\tlabel"];
12+
for (let i = 0; i < ROWS; i++) {
13+
lines.push(`${i}\t${(i * 1.1).toFixed(4)}\tcat_${i % 50}`);
14+
}
15+
const tsvContent = lines.join("\n");
16+
17+
for (let i = 0; i < WARMUP; i++) {
18+
readTable(tsvContent);
19+
}
20+
21+
const start = performance.now();
22+
for (let i = 0; i < ITERATIONS; i++) {
23+
readTable(tsvContent);
24+
}
25+
const total = performance.now() - start;
26+
27+
console.log(
28+
JSON.stringify({
29+
function: "read_table",
30+
mean_ms: total / ITERATIONS,
31+
iterations: ITERATIONS,
32+
total_ms: total,
33+
}),
34+
);

0 commit comments

Comments
 (0)