Browse Source

Add a script benchmark

signals
Gavin Howard 3 years ago
parent
commit
8bc48858bd
Signed by untrusted user who does not match committer: gavin
GPG Key ID: C08038BDF280D33E
  1. 4
      README.md
  2. 39
      manuals/benchmarks.md

4
README.md

@ -135,6 +135,10 @@ Because this `bc` packs more than `1` decimal digit per hardware integer, this
`bc` is faster than GNU `bc` and can be *much* faster. Full benchmarks can be
found at [manuals/benchmarks.md][19].
There is one instance where this `bc` is slower: if scripts are light on math.
This is because this `bc`'s intepreter is slightly slower than GNU `bc`, but
that is because it is more robust. See the [benchmarks][19].
## Algorithms
To see what algorithms this `bc` uses, see the [algorithms manual][7].

39
manuals/benchmarks.md

@ -143,3 +143,42 @@ real 0.81
user 0.81
sys 0.00
```
### Scripts
A script was created that contained the following:
```
#!/bin/sh
exe="$1"
for i in $(seq 0 1000); do
printf '%d\n' "$i" | "$exe" -q tests/bc/scripts/timeconst.bc > /dev/null
done
```
where `tests/bc/scripts/timeconst.bc` is [this file][1]. The script was saved at
`../test.sh`.
The command used was:
```
time -p sh ../test.sh [bc]
```
For GNU `bc`:
```
real 0.92
user 0.85
sys 0.17
```
```
real 1.01
user 0.96
sys 0.15
```
[1]: https://github.com/torvalds/linux/blob/master/kernel/time/timeconst.bc

Loading…
Cancel
Save