elm-explorations / elm-explorations/benchmark

Second function in `compare` reproducibly benchmarks faster than the first

Open
#18 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
28
Forks
4
PR merge metrics
No merged PRs in 30d

Description

With the use of `compare`, if identical functions are supplied, the second will reproducibly benchmark ~10-30% faster than the first, regardless of what the functions are.

SSCCE:
```
module Test exposing (main)

import Benchmark exposing (Benchmark)
import Benchmark.Runner exposing (BenchmarkProgram, program)

main : BenchmarkProgram
main =
program suite

suite : Benchmark
suite =
Benchmark.compare "First vs. Second" "First" (\_ -> myFunction "zxcvbn") "Second" (\_ -> myFunction "zxcvbn")

myFunction : String -> String
myFunction =
String.reverse
```
and some results for various functions in `myFunction`:
![1](https://user-images.githubusercontent.com/2049163/69501205-a64ba200-0eb7-11ea-82a4-b0a4fcc5baff.png)
![2](https://user-images.githubusercontent.com/2049163/69501206-a6e43880-0eb7-11ea-94aa-1b32587ed5f2.png)
![3](https://user-images.githubusercontent.com/2049163/69501207-a6e43880-0eb7-11ea-892e-f76d1b1ae28a.png)

This behavior extends to more complex functions as well, just presenting simple ones here so as to eliminate variables.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.