Count newline bytes (0x0A) in a local text file. JavaScript and Rust compiled to WebAssembly scan the same chunks. The file is not uploaded.

File

Drop a text file here

TXT, CSV, JSON, LOG, or any other bytes. The scan does not parse a format.

Configuration

Engine

Each iteration reads the file again. Reported times are the median of those iterations. JavaScript runs before WebAssembly when both are selected.

Progress

Choose a file to begin.

This iteration
—
Complete
—
Elapsed
—
Processing throughput
—

Results

Run both engines to compare them on the same file.

File statistics

A separate pass over the same chunks. It is not part of the benchmark timings. It also records the offset of each newline, so Go to line can read one line without keeping the file.

Bytes
—
Scalars
—
Invalid sequences
—
Newlines
—
CRLF pairs
—
Lines
—
Longest line, bytes
—
Longest line, scalars
—
Scalars
Unicode scalar values. Each maximal ill-formed UTF-8 subsequence counts as one replacement.
Lines
A 0x0A byte ends a line. A final non-empty line with no newline counts. An empty file has zero lines. A bare carriage return does not end a line.
CRLF pairs
Newlines whose previous byte was 0x0D, including when that pair is split across two chunks. They are also included in the newline count.
Longest line
Excludes the newline and, for a CRLF pair, excludes the carriage return as well.

Search

An exact, case-sensitive byte pattern. The scan keeps the tail of each chunk, so a match split across a boundary still counts once. This pass is not part of the benchmark timings. The first 100 matches are shown with a short window around each one.

Go to line

Summarize stores one offset per newline. Go to line reads that range and nothing else. A line longer than 8 KiB is truncated on screen.

No line index yet. Summarize the file to build one.

What the numbers measure

Read time
Time spent waiting on slice().arrayBuffer(). Both engines use the same reads. It is kept separate from the scan.
JavaScript scan time
Time inside the loop over a Uint8Array that counts 0x0A, after the chunk is already in memory.
Wasm call time
Time inside append_chunk. wasm-bindgen copies the typed array into WebAssembly memory, then Rust scans that copy. The copy is included because a caller pays it.
Estimated transfer
After the timed iterations, the worker times probe_transfer on about 10 chunks. That call copies the bytes and returns the length. The median time per byte is scaled to the file size. It is an estimate, not a second pass over the whole file, and it is not included in the totals.
Estimated Wasm scan
Wasm call time minus the estimated transfer. If that difference is negative, the scan was smaller than the noise in the estimate and the value is omitted.
End-to-end time
Wall time for one iteration inside the worker, from the first read through the last counted byte. Drawing this page is outside the timer. A combined run reads the file for JavaScript first, so WebAssembly may then see a warmer operating-system cache. Use scan time and call time to compare processing. Read time is shown so that cache effect stays visible.
Throughput
File size divided by the median processing time, and again by the median end-to-end time. 1 MiB is 1024 × 1024 bytes.
Newline count
Bytes equal to 0x0A. Carriage returns are not counted. The count does not depend on chunk size. A mismatch means the comparison is invalid.

Preview

The first 64 KiB are decoded as UTF-8. The benchmark itself counts bytes and does not decode the file.

Select a file to preview its first 64 KiB.