Try it locally
Run two queries over the same four orders with HazelJS Frame and Simple Data Analysis. The script creates its own CSV, ranks stores by completed sales, and counts pending orders. Use Node.js 20 or later and an npm registry that serves HazelJS 2.2.0.
mkdir frame-example
cd frame-example
npm init -y
npm install @hazeljs/frame@2.2.0 @nshiab/simple-data-analysis@6.0.10
Save this as compare.mjs.
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { count, fromCsv, sum } from '@hazeljs/frame';
import { SimpleDB } from '@nshiab/simple-data-analysis';
const dir = mkdtempSync(join(tmpdir(), 'frame-example-'));
try {
const file = join(dir, 'sales.csv');
writeFileSync(file, [
'store,status,amountOre',
'Stockholm,completed,4500',
'Malmö,completed,2300',
'Stockholm,completed,1500',
'Malmö,pending,9000',
].join('\n'));
const sales = fromCsv(file, {
schema: { store: 'string', status: 'string', amountOre: 'bigint' },
});
const hazelTop = await sales
.filter('status', 'eq', 'completed')
.groupBy('store')
.aggregate({ grossOre: sum('amountOre') })
.sortBy('grossOre', 'desc')
.thenBy('store')
.head(2)
.toRows();
const pending = sales.filter('status', 'eq', 'pending');
const [{ orders: hazelPending }] = await pending
.groupBy()
.aggregate({ orders: count() })
.toRows();
const table = new SimpleDB().newTable('sales');
await table.loadData(file);
const sdaPending = await table.getRowCount({ conditions: "status = 'pending'" });
table.filter("status = 'completed'");
table.summarize({ columns: 'amountOre', by: 'store', stats: 'sum' });
table.sort({ sum: 'desc', store: 'asc' });
table.selectRows(2);
const sdaTop = (await table.getData()).map(({ store, sum }) => ({
store,
grossOre: BigInt(sum),
}));
console.log('Frame', hazelTop, 'pending:', Number(hazelPending));
console.log('Simple Data Analysis', sdaTop, 'pending:', Number(sdaPending));
} finally {
rmSync(dir, { recursive: true, force: true });
}
node compare.mjs
Both libraries should report Stockholm at 6000n öre and Malmö at 2300n öre, with one pending order. Change the pending order to completed and rerun to see Malmö move into first place.
Run the same queries in pandas
In the example directory, create a virtual environment for pandas.
python3 -m venv .venv
.venv/bin/python -m pip install pandas
Save this as compare.py. It reads the same four orders from an inline CSV.
from io import StringIO
import pandas as pd
sales = pd.read_csv(StringIO("""store,status,amountOre
Stockholm,completed,4500
Malmö,completed,2300
Stockholm,completed,1500
Malmö,pending,9000
"""))
top = (
sales[sales["status"] == "completed"]
.groupby("store", as_index=False)["amountOre"]
.sum()
.rename(columns={"amountOre": "grossOre"})
.sort_values(["grossOre", "store"], ascending=[False, True])
.head(2)
)
print(top.to_dict("records"))
print("Pending:", (sales["status"] == "pending").sum())
.venv/bin/python compare.py
Benchmark results
HazelJS Frame was fastest across all five verified queries in this 100,000-row benchmark on an Apple M3 Max (arm64, Node.js 23.10.0). Returning the five highest-grossing stores took 4.8 ms, about 69% less time than Simple Data Analysis in the same query benchmark. Measured samples and medians
| Workload | HazelJS Frame (ms) | Simple Data Analysis (ms) | pandas (ms) | danfo.js (ms) |
|---|---|---|---|---|
| Top five stores by completed SEK sales | 4.8 | 15.5 | 44.9 | 176.1 |
| Completed sales totals by currency | 4.0 | 14.6 | 45.1 | 165.9 |
| Order counts by status | 2.6 | 14.0 | 40.5 | 144.9 |
| Pending order count | 2.9 | 28.7 | 39.2 | 124.0 |
| Top ten completed high-value orders | 4.3 | 15.2 | 43.6 | 175.8 |
What the benchmark measures
Each value is the median of five verified runs. Every worker starts in a fresh process. The warm query clock starts after library and engine warm-up. It includes reading the file, running the query, and materializing the result rows. Frame and Simple Data Analysis both use DuckDB. They read Parquet, as does pandas. The danfo.js worker uses a CSV with the same source records, so its result includes CSV parsing.
For one-shot jobs, the top-five query's median cold times were 223.3 ms for Frame, 268.2 ms for Simple Data Analysis, 406.2 ms for pandas, and 681.7 ms for danfo.js. The cold clock starts at process launch and includes imports and engine startup.
Reproduce this benchmark
Run from a HazelJS source checkout with Node.js 20 or later and Python 3. Repeat the last command five times to collect the same number of samples.
npm ci
npm run build -w @hazeljs/frame
cd benchmarks/frame
npm ci
python3 -m venv .venv
.venv/bin/pip install pandas pyarrow
npm start -- 100000
Each run prints warm query times, verification status, and a cold top-five sample. Frame package guide
FAQ
- What counts toward a warm query time?
- The worker times the file read, query, and result rows after library startup. The separate cold measurement includes process startup and imports.
- Which file format does each library read?
- Frame, Simple Data Analysis, and pandas read Parquet. The danfo.js benchmark reads a CSV with the same records.