Skip to content
Docs: PerformanceMenu

Performance

How Hypaxel's write, read and browser benchmarks were measured, why writing and reading are fast, what compression trades, and how to reproduce them.

v0.3.0 unreleasedLast updated View as Markdown

Each Hypaxel implementation ships its own benchmark, which compares it with the established XLSX writers of its ecosystem. The streaming readers in .NET, Rust, Python, Go and Java have read benchmarks against the established readers, and the WebAssembly build of the Node.js package has a browser benchmark against SheetJS and ExcelJS. This page explains how those benchmarks were run, where the speed comes from, and how to reproduce them. The result tables are on Benchmarks.

Methodology#

The dataset#

Every benchmark writes the same kind of table: 10 columns per row with a mix of integers, strings, floating-point numbers, a date-time, a boolean and one string that is unique per row, so the inline string path cannot benefit from repetition. The exact column types follow each language’s natural types (for example decimal in .NET, BigDecimal in Java, a Date in Node.js), so there are minor differences in composition. Most benchmarks report 100,000 and 1,000,000 rows.

What is measured#

  • Time to write the whole workbook.
  • Memory, in the form each runtime reports best: allocated bytes (.NET, Go, Java), peak Python memory, peak resident set size of the process (Node.js, Go, Java), or memory_get_peak_usage(true) (PHP). Peak RSS includes the runtime and the libraries themselves.
  • File size where it differs, for example between compression levels or libraries.

The destination is usually in memory or discarding (a MemoryStream, a Vec<u8>, a stream that discards the bytes); the PHP benchmark writes from a generator to a file.

The read files#

The read benchmarks read files written by the Hypaxel writer from the same kind of table, once with inline strings and once with a shared string table, and visit every cell:

  • .NET: 1,000,000 rows, inline and shared strings.
  • Rust: 1,000,000 rows, inline strings (49 MB) and shared strings (52 MB).
  • Python: 100,000 rows plus a header row, saved with a shared string table as Excel does. The 1,000,000-row file is 55 MB.
  • Go: 1,000,000 rows, inline strings (70.7 MB) and shared strings (71.5 MB). These files carry a cell reference on every cell, as Excel writes them, because two of the compared readers need them. That makes them about 40% larger than the other benchmarks’ files.
  • Java: 1,000,000 rows, inline strings (40.7 MB) and shared strings (43.0 MB, 1M distinct strings).

Because one string is unique per row, the shared string table of a 1,000,000-row file holds 1M distinct strings.

What is measured when reading#

  • Time to read the worksheet cell by cell.
  • Peak RSS of the process. In .NET it covers the whole process including the runtime (/usr/bin/time -l); in Python it covers Python, modules and native memory; in Java it comes from a separate single read in a fresh JVM with default settings.
  • Allocations where the runtime reports them: allocated bytes for one run (.NET), bytes allocated by the reading thread per run (Java), and bytes and allocation counts from go test -bench -benchmem (Go).
  • A checksum that every reader must reproduce. In .NET and Java it is 10,000,000 cells, the sum of all numbers including date serials, 42,833,558 characters of text and 500,000 TRUEs. In Go it is rows, cells, the sum of numbers, dates as Unix seconds, string bytes and the TRUE count, which the harness verifies. In Rust it is a checksum over all values. In Python all readers return the same 1,000,010 non-empty cells.

Every reader runs in its own process in .NET, Rust, Python and Go. Python does not time the imports. In Java the times come from runs in one JVM and the peak RSS from a separate read in a fresh JVM.

The browser benchmark#

The browser benchmark turns the same 10 columns as the Node.js write benchmark into an XLSX Blob in headless Chrome, at 100,000 and 300,000 rows. The rows are built before timing, and every library gets the same array. Each library runs in a fresh browser, and the time is the median of three runs after the library has loaded. SheetJS writes with compression: true. Hypaxel’s WebAssembly memory stayed at 2.4 MB in both runs; the browser does not expose the peak JavaScript heap, so memory is not compared across libraries.

Where each run happened#

BenchmarkMachineRuntimeCompared with
.NET, writingApple M1 Max (10 cores, macOS 26.6).NET 8.0.34, 9.0.23, 10.0.15, 11.0.0SpreadCheetah 1.29.0, ClosedXML 0.105.1
.NET, readingApple M1 Max (10 cores, 64 GB, macOS 26.6).NET 8.0.19, 9.0.0, 10.0.13, 11.0.0Sylvan.Data.Excel 0.5.8, ExcelDataReader 3.9.0, MiniExcel 1.47.1
Rust, writingLinux, Xeon 2.1 GHz, 4 vCPUsRust 1.97, --releaserust_xlsxwriter 0.102
Rust, readingApple M1 Max (macOS)Rust 1.100, --releasecalamine 0.38
Python, writingLinux, Xeon 2.1 GHzPython 3.13XlsxWriter, openpyxl, pandas.to_excel, polars.write_excel
Python, readingApple M1 Max (macOS)Python 3.13openpyxl 3.1.5, python-calamine 0.9.1, fastexcel 0.21.0, pandas 3.1.1, polars 2.1.0
Node.js, writingApple M1 Max (macOS 26.6)Node.js 22.23.2ExcelJS 4.4.0
Browsers (WebAssembly)Apple M1 Max (macOS 26.6)Chrome 158.0.8127.36, headlessSheetJS 0.20.3, ExcelJS 4.4.0
Go, writingApple M1 Max (10 cores, macOS 26.6)Go 1.27.4excelize 2.11.1
Go, readingApple M1 Max (10 cores, macOS 26.6)Go 1.27.4excelize 2.11.1, thedatashed/xlsxreader 1.2.8, tealeg/xlsx 3.3.13
Java, writingApple M1 Max (10 cores, macOS 26.6)OpenJDK 24.0.1FastExcel 0.20.2, Apache POI 6.0.0 (SXSSF)
Java, readingApple M1 Max (10 cores, 64 GB, macOS 26.6)OpenJDK 24.0.1FastExcel reader 0.20.2 (ReadableWorkbook), Apache POI 6.0.0 (XSSFReader with a SAX handler)
PHP, writingApple M1 Max (macOS 26.6)PHP 8.4.8 (CLI, NTS), opcache off and with tracing JITOpenSpout 5.14.1, PhpSpreadsheet 5.11.0

Single runs and benchmark harnesses#

The rigor differs per implementation, and the tables should be read accordingly:

  • .NET: 100k rows with BenchmarkDotNet 0.15.8 (ShortRun, in-process toolchain). 1M rows with a stopwatch runner that times a single run after one warm-up.
  • Rust: 100k rows with Criterion; 1M rows with a stopwatch run.
  • Python: a benchmark script; each figure is from that script’s run.
  • Node.js: single runs, each case in its own process. Treat small differences as noise. The write table also has a row for the WebAssembly engine running in Node.js; it is about 1.5x slower than the native module, which is why Node.js uses the native one.
  • Go: time and allocations from go test -bench (about a dozen iterations per case at 100k rows, three at 1M); peak RSS from separate runs, one process per case. Other processes were using the machine.
  • Java: 100k rows with JMH 1.37 (2 forks, 5 warm-up and 5 measured iterations of 2 s, GC profiler for allocation); 1M rows with a stopwatch runner (mean of 5 runs after 2 warm-ups), peak RSS from a separate single run in a fresh JVM. The machine had a load average of about 10.
  • PHP: single runs, each case in its own process, while the machine was busy with other work.

For reading:

  • .NET: the --read-quick stopwatch runner, each reader in its own process: one warm-up, then the best of three runs. The machine was otherwise idle. A BenchmarkDotNet run at 100k rows exists but is not used for the tables.
  • Rust: each run in its own process, best of three.
  • Python: a benchmark script, each reader in its own process.
  • Go: each reader in its own process, best of three, on an otherwise idle machine. Allocations come from go test -bench at 100k rows.
  • Java: mean of 5 runs after 2 warm-ups in one JVM; peak RSS from a separate single read in a fresh JVM. The machine was running other work (load average about 12), so treat differences of a few percent as noise.
  • Browsers: median of three runs, each library in a fresh browser.

Comparison libraries were configured as streaming writers where they offer one (for example XlsxWriter’s constant_memory, openpyxl’s write_only, excelize’s StreamWriter, POI’s SXSSF with a 100-row window, FastExcel flushed every 100 rows); in-memory variants are listed separately where they were measured.

Why writing is fast#

The implementations are independent, but they apply the same techniques.

Hand-written XML#

No XML library is involved. Markup is appended as precomputed byte literals to one reused buffer, and text is escaped and transcoded to UTF-8 in a single pass. Clean text is copied in one go: .NET uses SearchValues and the vectorized UTF-16 to UTF-8 transcoder, Rust uses table-driven escaping and a single memcpy, PHP validates and detects escapes with a single preg_match. Numbers are formatted straight into the buffer (integer fast paths for integral floats, integer-only arithmetic for date serials), and the typed write paths in .NET, Go and Java create no objects per cell.

Compact XML#

Cell references such as r="B7" are only written after a gap. The format allows this, and it removes about 20% of the XML that has to be compressed. Readers that require a reference on every cell can get one with the cell references option; see Troubleshooting.

A streaming ZIP container#

The XLSX container is a ZIP file. The Rust core (and with it the Python and Node.js packages), Java and PHP write their own streaming ZIP: entries are deflated directly into the output buffer with data descriptors, so nothing is patched after it is written, nothing is buffered per entry, and the destination never has to seek. ZIP64 is used automatically for very large parts. The .NET implementation uses ZipArchive, whose output goes to a pooled buffer that is drained to the destination with real async I/O.

Deflate level 1 by default#

Compression is the largest single cost. In Rust, about half of the run time is deflate (zlib-rs at level 1); in Java, about 70% of the time at level 1 is spent in the JDK’s Deflater. Hypaxel therefore defaults to the fastest level that still compresses well.

Bounded buffering#

Compressed output is buffered up to a flush threshold (64 KiB by default) and then written in one call, synchronously or asynchronously. In .NET this means about 64 KiB of XML plus about 96 KiB of compressed output per concurrent export; in Rust about 200 KiB of buffers per workbook. Memory does not grow with the row count, with two exceptions: shared strings keep every distinct string, and auto-fit holds back up to its sample (at most 8 MiB of XML).

Compression trade-off#

All implementations let you set the deflate level (0–9). Level 1 is the default. Higher levels give smaller files for considerably more CPU time; level 0 stores without compressing. Within one implementation the effect is consistent:

  • Rust: level 6 makes files about 40% smaller at about 4x the CPU (31 MB instead of 50 MB for 1M rows).
  • Go: at 1M rows, level 6 gives 29.0 MB in 1.32 s, level 0 gives 331 MB in 0.37 s, against 40.5 MB in 0.92 s at level 1.
  • Java: at 1M rows, level 6 gives 29.9 MB in 3.24 s, against 38.8 MB in 1.20 s at level 1.

In .NET the setting is CompressionLevel.Fastest (the default) or CompressionLevel.Optimal for smaller files.

Shared strings are a related trade-off: they can make files smaller when text repeats, but memory grows with the number of distinct strings and writing is somewhat slower.

Why reading is fast#

The readers in .NET, Rust, Go and Java are independent; the Python package reads through the Rust core. They stream rows, with memory bounded by the workbook’s shared strings plus one row, and they share most of their techniques.

A purpose-built pull parser#

.NET, Java and Go use purpose-built parsers instead of their platform’s XML APIs. .NET and Java parse UTF-8 bytes with their own pull parser and compare element and attribute names as bytes, so names never become strings; Java ignores namespace prefixes by matching local names. In .NET, a prototype that did the same work with System.Xml.XmlReader took 1.90 s and allocated 623 MB on the inline file, against 1.57 s and 161 MB for the first version of the own parser. The Go parser tokenizes the worksheet XML at 460 MB/s, 7x faster than encoding/xml’s RawToken (64 MB/s) on the same input.

Whole cells in one pass#

The cell shapes nearly every producer writes, such as <c r="B2" s="1"><v>42</v></c> and <c t="inlineStr"><is><t>…</t></is></c>, and plain shared string items are recognized with their attributes in a single scan (.NET, Rust, Go and Java). Anything else, such as formulas, rich text, namespace prefixes or comments, goes through the general parser, so both paths give the same result. In .NET this took the inline file from 1.02 s to 0.79 s and the shared file from 1.12 s to 0.86 s, measured interleaved against the previous version.

No objects per cell#

Rows are kept in buffers that are reused from row to row. In Rust, reading allocates nothing per cell. .NET stores cells as compact structs in a reused array, with text in one reused char buffer, and materializes values only when you ask for them. Java uses parallel primitive arrays, keeps text as UTF-8 until you ask for a String, and creates shared strings once, when the table is loaded.

Numbers parsed in place#

In .NET, numbers, shared-string indexes and booleans are parsed straight from the input buffer, which is about 4% faster than copying them out first. Decimals with up to 15 digits and no exponent are computed as digits / 10^k, which is correctly rounded because both operands are exact doubles, and everything else falls back to double.TryParse. Java uses Clinger’s fast path for up to 15 digits and then the Eisel-Lemire algorithm for up to 19 digits, leaving only the rare rest to the JDK; the results are bit-identical to Double.parseDouble.

Decompression and integrity checks#

Inflate is a large part of reading: about a quarter of the time in Rust, and about 25% of the time in Java together with CRC-32 verification. In Go, inflate and CRC-32 take as long as all the parsing, so each sheet and the shared string table are decompressed on a separate goroutine while the caller’s goroutine parses (WithConcurrentInflate); a single reader’s time is then bounded by inflate alone. The .NET reader inflates with the runtime’s native zlib and verifies CRC-32 itself, with the ARM64 CRC instructions where available and a slicing-by-8 table elsewhere; its optional BackgroundDecompression moves inflating off the parsing thread, which saves about 30% of the time when cores are idle but costs about 20% more CPU and makes the total slower when every core is busy, so it is off by default. Java has its own ZIP reader that inflates with positional reads directly into the parser’s buffer, which also lets several worksheets be read at once.

How to reproduce#

The benchmark code lives in each implementation’s directory in the repository.

.NET#

Pick the .NET version with -f:

cd dotnet/benchmarks/Hypaxel.Benchmarks
dotnet run -c Release -f net10.0 -- --quick 1000000                         # quick stopwatch run
dotnet run -c Release -f net10.0 -- --filter '*' --job short --inProcess    # BenchmarkDotNet run

--inProcess is required on .NET 11, which BenchmarkDotNet 0.15.8 does not recognise otherwise.

Reading:

cd dotnet/benchmarks/Hypaxel.Benchmarks
dotnet run -c Release -f net10.0 -- --read-quick 1000000                    # all readers, both files
dotnet run -c Release -f net10.0 -- --read-quick 1000000 Sylvan shared      # one reader, one file
dotnet run -c Release -f net10.0 -- --filter '*ReadBenchmarks*' --job short --inProcess   # BenchmarkDotNet, 100k rows (not used for the tables)

The test files are generated in the temp directory on first use.

Rust#

cargo bench -p hypaxel                          # Criterion, 10k and 100k rows
HYPAXEL_QUICK=1000000 cargo bench -p hypaxel    # stopwatch run, 1M rows

Reading:

cargo run --release -p hypaxel --example read_bench -- generate data.xlsx 1000000 inline
cargo run --release -p hypaxel --example read_bench -- hypaxel data.xlsx     # or calamine, calamine-stream

Python#

python benchmarks/bench.py 100000

Reading needs the comparison readers as extras (uv pip install python-calamine fastexcel pyarrow):

python benchmarks/read_bench.py 100000

Node.js#

node benchmarks/bench.mjs            # 100,000 rows
node benchmarks/bench.mjs 1000000

Browsers (WebAssembly):

npm run bench:browser                        # 100,000 rows; needs Chrome (or set CHROME_PATH)
node benchmarks/browser/run.mjs 300000

Go#

cd go/tests
go test -run '^$' -bench Write -benchmem                                 # 100,000 rows
go test -run '^$' -bench Write -benchmem -rows 1000000 -benchtime 3x     # 1,000,000 rows
go run ./cmd/bench                                                       # peak RSS, 100,000 rows
go run ./cmd/bench 1000000
go test -run '^$' -bench Read -benchmem                                  # every reader, 100,000 rows
go run ./cmd/bench read 1000000                                          # time and peak RSS

Java#

The benchmarks are a separate Maven project in benchmarks/, so JMH, FastExcel and POI are not dependencies of the library.

cd java
./mvnw -q -DskipTests install                       # the benchmarks use the installed library
./mvnw -q -f benchmarks/pom.xml package
java -jar benchmarks/target/benchmarks.jar jmh WriteBenchmark -prof gc    # 100k rows, JMH
./benchmarks/run.sh 1000000                         # 1M rows: stopwatch and peak memory

Reading, from the same java directory:

./mvnw -q -DskipTests install
./mvnw -q -f benchmarks/pom.xml package
./benchmarks/read.sh 1000000                        # generates the files, then time and peak memory

PHP#

php benchmarks/bench.php                  # 100,000 rows
php benchmarks/bench.php 1000000
php benchmarks/bench.php 100000 --jit     # opcache + tracing JIT