/argparse-benchmarks-rs

Collected benchmarks for arg parsing crates written in Rust

Primary LanguagePythonMIT LicenseMIT

Rust Arg Parsing Benchmarks

This repo tries to assess Rust arg parsing performance.

We currently compare:

Name Style Notes
No-op N/A N/A
argh derive
bpaf Combinator
clap Builder or derive Color, suggested fixes, completions
gumpdrop derive
lexopt Imperative No help generation
pico-args Imperative No help generation
structopt derive Color, suggested fixes, completions
xflags proc-macro

Note: any non-performanve comparison is meant to provide context for what you gain/lose with each crate's overhead. For a full comparison, see each parser docs

Results

Name Overhead (release) Build (debug) Parse (release) Invalid UTF-8 Downloads Version
null 0 KiB 639ms 3ms Y Download count -
argh 37 KiB 5s 3ms N Download count v0.1.7
bpaf 145 KiB 1s 4ms Y Download count v0.3.0
clap 591 KiB 6s 4ms Y Download count v3.1.6
clap-minimal 549 KiB 5s 4ms Y Download count v3.1.6
clap_derive 588 KiB 12s 3ms Y Download count v3.1.6
gumdrop 32 KiB 5s 4ms N Download count v0.8.1
lexopt 35 KiB 866ms 3ms Y Download count v0.2.0
pico-args 31 KiB 867ms 4ms Y Download count v0.4.2
xflags 22 KiB 1s 3ms Y Download count v0.2.4

System: Linux 5.4.0-104-generic (x86_64) w/ -j 8

Notes:

  • Overhead will be lower if your application shares dependencies with your argument parsing library.

Running the Benchmarks

$ ./bench.py
$ ./format.py

To be included, the crate needs meet one of the following criteria:

  • 10k+ recent downloads
  • Unique API design

Special Thanks