Skip to content

gnutr ran 11.91 ± 0.22 times faster than coreutils tr #8439

@julian-klode

Description

@julian-klode

After truncate -s 1G zeroes

jak@jak-t14-g3 ~/P/U/uutils (main)> hyperfine 'gnutr a b < zeroes' './target/release/tr a b < zeroes'
Benchmark 1: gnutr a b < zeroes
  Time (mean ± σ):     586.0 ms ±   9.8 ms    [User: 348.2 ms, System: 237.5 ms]
  Range (min … max):   579.7 ms … 613.4 ms    10 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Benchmark 2: ./target/release/tr a b < zeroes
  Time (mean ± σ):      6.977 s ±  0.050 s    [User: 5.744 s, System: 1.230 s]
  Range (min … max):    6.902 s …  7.044 s    10 runs

Summary
  gnutr a b < zeroes ran
   11.91 ± 0.22 times faster than ./target/release/tr a b < zeroes

The changes in #8435 may improve that a bit:

jak@jak-t14-g3 ~/P/U/uutils (tr-enomem)> hyperfine 'gnutr a b < zeroes' './target/release/tr a b < zeroes'
Benchmark 1: gnutr a b < zeroes
  Time (mean ± σ):     578.8 ms ±   2.2 ms    [User: 349.6 ms, System: 228.8 ms]
  Range (min … max):   575.4 ms … 582.8 ms    10 runs

Benchmark 2: ./target/release/tr a b < zeroes
  Time (mean ± σ):      5.678 s ±  0.058 s    [User: 5.434 s, System: 0.242 s]
  Range (min … max):    5.565 s …  5.760 s    10 runs

Summary
  gnutr a b < zeroes ran
    9.81 ± 0.11 times faster than ./target/release/tr a b < zeroes

But there's something fundamentally wrong somewhere. Probably because there's no 'a' in the input file, and tr may be vectorizing the search for a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions