Skip to content

wc -l appears to be consistently slower than gnu implementation #7929

@jnsgruk

Description

@jnsgruk

I was experimenting with wc -l against the 1 Billion Rows Challenge dataset today.

Running against the GNU implementation, it seems that uutils' implementation doesn't quite perform as well:

❯ hyperfine --warmup 3 "wc -l measurements.txt" "/usr/lib/cargo/bin/coreutils/wc -l measurements.txt"
Benchmark 1: wc -l measurements.txt
  Time (mean ± σ):      1.846 s ±  0.005 s    [User: 0.158 s, System: 1.685 s]
  Range (min … max):    1.836 s …  1.856 s    10 runs

Benchmark 2: /usr/lib/cargo/bin/coreutils/wc -l measurements.txt
  Time (mean ± σ):      2.128 s ±  0.008 s    [User: 0.520 s, System: 1.601 s]
  Range (min … max):    2.120 s …  2.147 s    10 runs

Summary
  wc -l measurements.txt ran
    1.15 ± 0.01 times faster than /usr/lib/cargo/bin/coreutils/wc -l measurements.txt

Where measurements.txt is just a very large text file with 1 billion short lines.

I was discussing with @sylvestre this morning, and he can also reproduce. I tried with both 0.0.24 and 0.0.30 on Ubuntu 24.04 LTS.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions