Documentation

Beijing CSV benchmarks

Beijing CSV benchmarks

The Five years of Beijing air quality with Arx uses the Beijing PM2.5 dataset, Song Chen (2015), available under CC BY 4.0.

All four workloads start by parsing that same CSV and selecting the year, month, day, hour, and PM2.5 fields. The programs rename pm2.5 to pm25 and preserve NA as null. The CSV has one chronological row per hour, so the peak analysis slices the Series at five known calendar year boundaries.

Workload After loading Expected output in order
inventory Count rows 43824
summary Count observations and nulls, calculate mean, find maximum 41757, 2067, 98.613215, 994
annual-peaks Slice into calendar years and find five maxima 980, 595, 994, 886, 671
archive Write the selected columns to Zstandard-compressed Parquet 43824 and beijing-pm25.parquet

The Arx programs share readings.x. The reference implementations are reference.py for PyArrow and arrow.cpp for C++.

Build and verify on Linux

Run these commands from the repository root with Python, Clang, a C++ compiler, and Hyperfine available. The reported measurements used Arx 1.33.0, CPython 3.14.10, Clang 19.1.7, Arrow/PyArrow 26.0.1, and Hyperfine 1.19.0.

python -m pip install 'arxlang==1.33.0' 'pyarrow==26.0.1'
src="$PWD/docs/blog/beijing-air-quality-with-arx"
work="$(mktemp -d)"
cp "$src"/*.x "$work/"
cd "$work"
curl -fL -o beijing-pm25.csv \
  'https://archive.ics.uci.edu/ml/machine-learning-databases/00381/PRSA_data_2010.1.1-2014.12.31.csv'

for task in inventory summary annual-peaks archive; do
  arx "$task.x" --output-file "$task-arx"
done

arrow_dir="$(python -c 'import pyarrow as pa; print(pa.get_library_dirs()[0])')"
clang++ -std=c++20 -O2 -I "$arrow_dir/include" \
  "$src/arrow.cpp" -L "$arrow_dir" -Wl,-rpath,"$arrow_dir" \
  -l:libparquet.so.2600 -l:libarrow_compute.so.2600 -l:libarrow.so.2600 \
  -o arrow-cpp

for task in inventory summary annual-peaks archive; do
  "./$task-arx" > "$task.expected"
  ./arrow-cpp "$task" | diff -u "$task.expected" -
  python "$src/reference.py" "$task" | diff -u "$task.expected" -
done

Each archive command overwrites beijing-pm25.parquet in the scratch directory. The five columns should be nullable 64-bit integers. A Parquet reader should report 43,824 rows and 2,067 nulls in pm25.

Time complete commands

for task in inventory summary annual-peaks archive; do
  hyperfine --shell=none --warmup 5 --runs 30 --export-json "$task.json" \
    "./$task-arx" "./arrow-cpp $task" "python '$src/reference.py' $task"
done

Use the median field from each JSON file. Timing includes startup, imports, warm-cache CSV I/O and parsing, and the selected task. Each CSV parser uses one thread and a 4 MiB block. Downloading the CSV and building the programs happen before timing.

Search documentation

Type to search.