File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }))
Original file line number Diff line number Diff line change 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+ ) ;
You can’t perform that action at this time.
0 commit comments