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 withbuildandtest.
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
Runtime
smaller is betterAllocation count
smaller is betterRuntime allocated bytes
smaller is betterStripped binary size
smaller is betterCompile 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.
| Case | Library | Runtime | Allocs | Bytes | Stripped size | Compile time |
|---|---|---|---|---|---|---|
| Simple | cli20 | 253.5 ns | 0 allocs | 0 B | 87.3 KiB | 1.57 s |
| Simple | CLI11 | 3,008.4 ns | 81 allocs | 4.15 KiB | 371.9 KiB | 3.74 s |
| Simple | argparse | 1,419 ns | 34 allocs | 3.47 KiB | 120.8 KiB | 1.78 s |
| Simple | cxxopts | 9,319.8 ns | 330 allocs | 21.4 KiB | 170.5 KiB | 2.08 s |
| Simple | Boost* | 2,788.3 ns | 86 allocs | 5 KiB | 38.2 KiB | 0.88 s |
| Many options | cli20 | 2,732.9 ns | 0 allocs | 0 B | 211 KiB | 2.16 s |
| Many options | CLI11 | 17,231.5 ns | 503 allocs | 22.8 KiB | 404.4 KiB | 3.51 s |
| Many options | argparse | 5,357.3 ns | 98 allocs | 13.7 KiB | 139.3 KiB | 1.82 s |
| Many options | cxxopts | 42,829.3 ns | 1,489 allocs | 123.5 KiB | 187.8 KiB | 2.19 s |
| Many options | Boost* | 20,222.5 ns | 412 allocs | 27 KiB | 108.5 KiB | 1.14 s |
| Subcommand | cli20 | 201 ns | 0 allocs | 0 B | 120.2 KiB | 1.59 s |
| Subcommand | CLI11 | 3,681.5 ns | 107 allocs | 6.95 KiB | 372.1 KiB | 3.26 s |
| Subcommand | argparse | 2,284.8 ns | 64 allocs | 5.78 KiB | 120.9 KiB | 1.58 s |
| Subcommand | cxxopts | 2,855.4 ns | 105 allocs | 7.59 KiB | 170.5 KiB | 1.8 s |
| Subcommand | Boost* | 960.1 ns | 36 allocs | 1.71 KiB | 37.7 KiB | 0.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.
| Area | Source |
|---|---|
| Runtime benchmarks | bench/runtime/ |
| Binary size benchmarks | bench/size/ |
| Compile-time benchmarks | bench/compile_time/ |
| Shared argv/allocation helpers | bench/include/bench/ |
| Result summarization | bench/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.