docs: Add benchmark

This commit is contained in:
Kalle Carlbark 2023-10-29 16:36:26 +01:00
parent 2379f87ca1
commit 7674e7d0d8
No known key found for this signature in database

View file

@ -8,10 +8,12 @@ A tool I created to
## Usage ## Usage
``` ```
Usage: b64 [-e] [-d] <string> Usage: b64 [-e] [-d] <string>
-h, --help -h, --help
Display this help and exit. Display this help and exit.
-b, --benchmark
Benchmark b64
-d, --decode -d, --decode
Decode base64 to string. Decode base64 to string.
@ -47,10 +49,49 @@ encode this string to base64
$ $
``` ```
### Benchmark
```shell
zig build
./zig-out/bin/b64 -b
encode
280335 iterations 12401.51ns per iterations
40 bytes per iteration
worst: 138209ns median: 10042ns stddev: 318640155486692400.00ns
decode
282250 iterations 12048.95ns per iterations
28 bytes per iteration
worst: 76416ns median: 10125ns stddev: 318604539142680300.00ns
zig build -Doptimize=ReleaseSafe
./zig-out/bin/b64 -b
encode
1284225 iterations 1228755.55ns per iterations
40 bytes per iteration
worst: 0ns median: 416ns stddev: 86582387.80ns
decode
2295809 iterations 1226658.46ns per iterations
28 bytes per iteration
worst: 0ns median: 375ns stddev: 86582411.15ns
zig build -Doptimize=ReleaseFast
./zig-out/bin/b64 -b
encode
1355137 iterations 93007.39ns per iterations
40 bytes per iteration
worst: 526709ns median: 83ns stddev: 37608456664387784.00ns
decode
2729217 iterations 105389.71ns per iterations
28 bytes per iteration
worst: 535583ns median: 83ns stddev: 36170163385699460.00ns
```
## Build ## Build
```shell ```shell
$ git clone https://git.kcbark.net/zig/b64.git && cd b64 $ git clone https://git.kcbark.net/zig/b64.git && cd b64
$ zig build -Doptimize=ReleaseFast $ zig build -Doptimize=ReleaseFast
$ cp zig-out/bin/b64 ~/.local/bin $ cp zig-out/bin/b64 ~/.local/bin
``` ```