clap aims to be extremely fast and efficient. Arguments will be parsed without wasting CPU cycles or hogging memory.
Because let’s face it, your application is the star of the show!
How fast? In the benches repository of the project, you will find a mock up of a popular command line tool which contains many, many options, switches/flags, validation layers, and then parses a very complex set of arguments using most of clap’s features. This parse takes ~0.019 ms on a laptop i7-6700k! Yes, that’s around two-one-hundredths of a millisecond.
If you already have Rust installed and want to run the benchmarks for yourself to compare, run the following commands after cloning the clap repository to your local machine:
Note: the benchmarks need to be run using a Nightly Rust compiler.
$ cd clap-rs
$ cargo bench --bench 05_ripgrep -- parse_complex
Finished release [optimized] target(s) in 0.0 secs
running 1 test
test parse_complex ... bench: 19,494 ns/iter (+/- 703)
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 6 filtered out
There are many more benchmarks to play around with if you’d like to see a workload more tailored to your specific use case.