Browse Source

Add benchmarks

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

25
README.md

@ -111,11 +111,29 @@ This `bc` can be used as a drop-in replacement for any existing `bc`. This `bc`
is also compatible with MinGW toolchains, though history is not supported on
Windows.
## Comparison to GNU `bc`
This `bc` compares favorably to GNU `bc`.
* It has more extensions, which make this `bc` more useful for scripting.
* This `bc` is a bit more POSIX compliant.
* It has a much less buggy parser. The GNU `bc` will give parse errors for what
is actually valid `bc` code, or should be. For example, putting an `else` on
a new line after a brace can cause GNU `bc` to give a parse error.
* This `bc` has fewer crashes.
* GNU `bc` will report errors when there are none. For example, `0 ^ -251`
causes GNU `bc` to report a divide by `0`.
* GNU `bc` will sometimes print numbers incorrectly. For example, when running
it on the file `tests/bc/power.txt` in this repo, GNU `bc` gets all the right
answers, but for some inexplicable reason, it fails to wrap the numbers at the
proper place.
* This `bc` is faster. (See [Performance](#performance).)
### Performance
This `bc` has similar performance to GNU `bc`. It is slightly slower on certain
operations and slightly faster on others. Full benchmark data are not yet
available.
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].
## Algorithms
@ -205,3 +223,4 @@ Folders:
[16]: https://codecov.io/gh/gavinhoward/bc
[17]: https://img.shields.io/coverity/scan/16609.svg
[18]: https://scan.coverity.com/projects/gavinhoward-bc
[19]: ./manuals/benchmarks.md

145
manuals/benchmarks.md

@ -0,0 +1,145 @@
# Benchmarks
These are the results of benchmarks comparing this `bc` (at version `2.0.0`) and
GNU `bc` (at version `1.07.1`).
Note: all benchmarks were run four time, and the fastest run is the one shown.
Also, `[bc]` means whichever `bc` was being run, and the assumed working
directory is the root directory of this repository. Also, this `bc` was built at
`-O2`.
### Addition
The command used was:
```
tests/script bc add.bc 0 1 1 [bc]
```
For GNU `bc`:
```
Running bc script: add.bc
real 0.80
user 0.37
sys 0.43
```
For this `bc`:
```
Running bc script: add.bc
real 0.56
user 0.55
sys 0.00
```
### Subtraction
The command used was:
```
tests/script bc subtract.bc 0 1 1 [bc]
```
For GNU `bc`:
```
Running bc script: subtract.bc
real 0.82
user 0.40
sys 0.42
```
For this `bc`:
```
Running bc script: subtract.bc
real 0.57
user 0.55
sys 0.01
```
### Multiplication
The command used was:
```
tests/script bc multiply.bc 0 1 1 [bc]
```
For GNU `bc`:
```
Running bc script: multiply.bc
real 5.74
user 3.95
sys 1.79
```
For this `bc`:
```
Running bc script: multiply.bc
real 2.59
user 2.55
sys 0.03
```
### Division
The command used was:
```
tests/script bc divide.bc 0 1 1 [bc]
```
For GNU `bc`:
```
Running bc script: divide.bc
real 2.89
user 1.62
sys 1.26
```
For this `bc`:
```
Running bc script: divide.bc
real 2.24
user 2.22
sys 0.01
```
### Power
The command used was:
```
printf '1234567890^100000; halt\n' | time -p [bc] -lq > /dev/null
```
For GNU `bc`:
```
real 12.08
user 12.08
sys 0.00
```
For this `bc`:
```
real 0.81
user 0.81
sys 0.00
```
Loading…
Cancel
Save