Skip to content

Commit 981081b

Browse files
[Autoloop: perf-comparison] Iteration 412: readParquet/toParquet benchmark
Add Parquet round-trip benchmark (10k rows × 3 cols, 20 iters). Covers readParquet and toParquet vs pandas read_parquet/to_parquet. Run: https://github.com/githubnext/tsb/actions/runs/29746441004 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ded4736 commit 981081b

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Benchmark: read_parquet / to_parquet — Parquet round-trip on 10k rows
3+
"""
4+
import json
5+
import time
6+
import io
7+
import pandas as pd
8+
import numpy as np
9+
10+
ROWS = 10_000
11+
WARMUP = 3
12+
ITERATIONS = 20
13+
14+
rng = np.random.default_rng(42)
15+
df = pd.DataFrame({
16+
"id": np.arange(ROWS, dtype=np.int64),
17+
"value": np.arange(ROWS, dtype=np.float64) * 1.1,
18+
"label": [f"cat_{i % 50}" for i in range(ROWS)],
19+
})
20+
21+
# Warm up
22+
for _ in range(WARMUP):
23+
buf = io.BytesIO()
24+
df.to_parquet(buf)
25+
buf.seek(0)
26+
pd.read_parquet(buf)
27+
28+
# Measure round-trip
29+
start = time.perf_counter()
30+
for _ in range(ITERATIONS):
31+
buf = io.BytesIO()
32+
df.to_parquet(buf)
33+
buf.seek(0)
34+
pd.read_parquet(buf)
35+
total = (time.perf_counter() - start) * 1000
36+
37+
print(json.dumps({
38+
"function": "readParquet",
39+
"mean_ms": total / ITERATIONS,
40+
"iterations": ITERATIONS,
41+
"total_ms": total,
42+
}))
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Benchmark: readParquet / toParquet — Parquet round-trip on 10k rows
3+
*/
4+
import { DataFrame, toParquet, readParquet } from "../../src/index.js";
5+
6+
const ROWS = 10_000;
7+
const WARMUP = 3;
8+
const ITERATIONS = 20;
9+
10+
// Build a DataFrame with int, float, and string columns
11+
const ids = Array.from({ length: ROWS }, (_, i) => i);
12+
const values = Array.from({ length: ROWS }, (_, i) => i * 1.1);
13+
const labels = Array.from({ length: ROWS }, (_, i) => `cat_${i % 50}`);
14+
15+
const df = new DataFrame({ id: ids, value: values, label: labels });
16+
17+
// Warm up
18+
for (let i = 0; i < WARMUP; i++) {
19+
const buf = toParquet(df);
20+
readParquet(buf);
21+
}
22+
23+
// Measure round-trip
24+
const start = performance.now();
25+
for (let i = 0; i < ITERATIONS; i++) {
26+
const buf = toParquet(df);
27+
readParquet(buf);
28+
}
29+
const total = performance.now() - start;
30+
31+
console.log(
32+
JSON.stringify({
33+
function: "readParquet",
34+
mean_ms: total / ITERATIONS,
35+
iterations: ITERATIONS,
36+
total_ms: total,
37+
}),
38+
);

0 commit comments

Comments
 (0)