Skip to main content

Benchmarks

This page compares cli20 against CLI11, argparse, cxxopts, and Boost.Program_options across three representative schemas. All benchmark metrics on this page are smaller is better.

  • simple: one flag, one option, and one required positional argument.
  • many_options: strings, integers, doubles, paths, and enum-like choices.
  • subcommand: a small command tree with build and test.

Boost.Program_options is shown as a reference value because it links against the Boost.Program_options shared library. Its binary-size numbers are therefore not directly comparable with the mostly header-only libraries.

Results​

Language mode

Runtime

smaller is better

Allocation count

smaller is better

Runtime allocated bytes

smaller is better

Stripped binary size

smaller is better

Compile time

smaller is better

* Boost.Program_options is a reference value: it links against the Boost.Program_options shared library, so binary-size results do not represent a fully self-contained executable in the same way as the header-oriented libraries.

CaseLibraryRuntimeAllocsBytesStripped sizeCompile time
Simplecli20253.5 ns0 allocs0 B87.3 KiB1.57 s
SimpleCLI113,008.4 ns81 allocs4.15 KiB371.9 KiB3.74 s
Simpleargparse1,419 ns34 allocs3.47 KiB120.8 KiB1.78 s
Simplecxxopts9,319.8 ns330 allocs21.4 KiB170.5 KiB2.08 s
SimpleBoost*2,788.3 ns86 allocs5 KiB38.2 KiB0.88 s
Many optionscli202,732.9 ns0 allocs0 B211 KiB2.16 s
Many optionsCLI1117,231.5 ns503 allocs22.8 KiB404.4 KiB3.51 s
Many optionsargparse5,357.3 ns98 allocs13.7 KiB139.3 KiB1.82 s
Many optionscxxopts42,829.3 ns1,489 allocs123.5 KiB187.8 KiB2.19 s
Many optionsBoost*20,222.5 ns412 allocs27 KiB108.5 KiB1.14 s
Subcommandcli20201 ns0 allocs0 B120.2 KiB1.59 s
SubcommandCLI113,681.5 ns107 allocs6.95 KiB372.1 KiB3.26 s
Subcommandargparse2,284.8 ns64 allocs5.78 KiB120.9 KiB1.58 s
Subcommandcxxopts2,855.4 ns105 allocs7.59 KiB170.5 KiB1.8 s
SubcommandBoost*960.1 ns36 allocs1.71 KiB37.7 KiB0.75 s

Benchmark Source​

The benchmark code is kept in the repository so every number on this page can be traced back to the parser setup being measured.

AreaSource
Runtime benchmarksbench/runtime/
Binary size benchmarksbench/size/
Compile-time benchmarksbench/compile_time/
Shared argv/allocation helpersbench/include/bench/
Result summarizationbench/scripts/

Method​

Runtime benchmarks construct the parser and parse the same argv every iteration. Allocation counts are measured inside the same operation.

Binary size benchmarks build one executable per library and case, then record both the unstripped and stripped file sizes.

Compile-time benchmarks compile one translation unit per library and case with hyperfine, using the same benchmark source as the binary-size targets.