-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial Haskell support #130
Open
charrsky
wants to merge
4
commits into
benchmark-action:master
Choose a base branch
from
charrsky:haskell-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Cabal Example | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: write | ||
deployments: write | ||
|
||
jobs: | ||
benchmark: | ||
name: Run Cabal benchmark example | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: haskell/actions/[email protected] | ||
- name: Run benchmark | ||
run: cd examples/cabal && cabal run -- --csv output.txt | ||
|
||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Cabal Benchmark | ||
tool: 'cabal' | ||
output-file-path: examples/cabal/output.txt | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
auto-push: true | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: '200%' | ||
comment-on-alert: true | ||
fail-on-alert: true | ||
alert-comment-cc-users: '@charrsky' | ||
|
||
- name: Store benchmark result - separate results repo | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Cabal Benchmark | ||
tool: 'cabal' | ||
output-file-path: examples/cabal/output.txt | ||
github-token: ${{ secrets.BENCHMARK_ACTION_BOT_TOKEN }} | ||
auto-push: true | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: '200%' | ||
comment-on-alert: true | ||
fail-on-alert: true | ||
alert-comment-cc-users: '@charrsky' | ||
gh-repository: 'github.com/benchmark-action/github-action-benchmark-results' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ This action currently supports the following tools: | |
- [BenchmarkTools.jl][] for Julia packages | ||
- [Benchmark.Net][benchmarkdotnet] for .Net projects | ||
- [benchmarkluau](https://github.com/Roblox/luau/tree/master/bench) for Luau projects | ||
- [criterion](https://hackage.haskell.org/package/criterion) for Haskell projects | ||
- Custom benchmarks where either 'biggerIsBetter' or 'smallerIsBetter' | ||
|
||
Multiple languages in the same repository are supported for polyglot projects. | ||
|
@@ -46,9 +47,11 @@ definitions are in [.github/workflows/](./.github/workflows) directory. Live wor | |
| Python | [![pytest-benchmark Example Workflow][pytest-benchmark-badge]][pytest-workflow-example] | [examples/pytest](./examples/pytest) | | ||
| C++ | [![C++ Example Workflow][cpp-badge]][cpp-workflow-example] | [examples/cpp](./examples/cpp) | | ||
| C++ (Catch2) | [![C++ Catch2 Example Workflow][catch2-badge]][catch2-workflow-example] | [examples/catch2](./examples/catch2) | | ||
| Julia | [![Julia Example][julia-badge]][julia-workflow-example] | [examples/julia](./examples/julia) | | ||
| Julia | [![Julia Example][julia-badge]][julia-workflow-example] | [examples/julia](./examples/julia) | | ||
| .Net | [![C# Benchmark.Net Example Workflow][benchmarkdotnet-badge]][benchmarkdotnet-workflow-example] | [examples/benchmarkdotnet](./examples/benchmarkdotnet) | | ||
| Luau | Coming soon | Coming soon | | ||
| Haskell | | | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add appropriate links here? |
||
|
||
|
||
All benchmark charts from above workflows are gathered in GitHub pages: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- The simplest/silliest of all benchmarks! | ||
|
||
import Criterion.Main | ||
|
||
fib :: Integer -> Integer | ||
fib m | m < 0 = error "negative!" | ||
| otherwise = go m | ||
where | ||
go 0 = 0 | ||
go 1 = 1 | ||
go n = go (n-1) + go (n-2) | ||
|
||
main :: IO () | ||
main = defaultMain [ | ||
bgroup "fib" [ bench "1" $ whnf fib 1 | ||
, bench "5" $ whnf fib 5 | ||
, bench "9" $ whnf fib 9 | ||
, bench "11" $ whnf fib 11 | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Cabal example for benchmarking with `criterion` | ||
================================================= | ||
|
||
- [Workflow for this example](../../.github/workflows/cabal.yml) | ||
- [Action log of this example](https://github.com/benchmark-action/github-action-benchmark/) | ||
- [Benchmark results on GitHub pages](https://benchmark-action.github.io/github-action-benchmark/dev/bench/) | ||
|
||
This directory shows how to use [`github-action-benchmark`](https://github.com/benchmark-action/github-action-benchmark) | ||
with `criterion` package. | ||
|
||
You can see a quick `criterion` tutorial [here](http://www.serpentine.com/criterion/tutorial.html). | ||
|
||
NB: As for now, this GitHub action only supports benchmarks made with `criterion` package outputted as a .csv file. | ||
|
||
## Run benchmarks | ||
|
||
If the file with the benchmarks is also a "benchmark" according to your .cabal file, then | ||
|
||
```yaml | ||
- name: Run benchmark | ||
run: cabal bench --benchmark-options="--csv <FILENAME>" | ||
``` | ||
|
||
should do the trick. If it is an "executable" (as it is in the example), then run it with | ||
|
||
```yaml | ||
- name: Run benchmark | ||
run: cabal run -- --csv <FILENAME>" | ||
``` | ||
|
||
## Process benchmark results | ||
|
||
Store the benchmark results with step using the action. | ||
|
||
```yaml | ||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
tool: 'cabal' | ||
output-file-path: <FILENAME> | ||
``` | ||
|
||
Please read ['How to use' section](https://github.com/benchmark-action/github-action-benchmark#how-to-use) for common usage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: fibber | ||
version: 0 | ||
synopsis: Examples for the criterion benchmarking system | ||
description: Examples for the criterion benchmarking system. | ||
homepage: https://github.com/haskell/criterion | ||
license: BSD3 | ||
license-file: LICENSE | ||
author: Bryan O'Sullivan <[email protected]> | ||
maintainer: Bryan O'Sullivan <[email protected]> | ||
category: Benchmarks | ||
build-type: Simple | ||
cabal-version: >=1.10 | ||
tested-with: | ||
GHC==7.4.2, | ||
GHC==7.6.3, | ||
GHC==7.8.4, | ||
GHC==7.10.3, | ||
GHC==8.0.2, | ||
GHC==8.2.2, | ||
GHC==8.4.4, | ||
GHC==8.6.5, | ||
GHC==8.8.4, | ||
GHC==8.10.7, | ||
GHC==9.0.2, | ||
GHC==9.2.2 | ||
|
||
flag conduit-vs-pipes | ||
default: True | ||
|
||
flag maps | ||
default: True | ||
|
||
executable fibber | ||
main-is: Fibber.hs | ||
|
||
default-language: Haskell2010 | ||
ghc-options: -Wall -rtsopts | ||
build-depends: | ||
base == 4.*, | ||
criterion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Name,Mean,MeanLB,MeanUB,Stddev,StddevLB,StddevUB | ||
fib/1,1.2128410840686445e-8,1.2074536540005714e-8,1.2202216975790019e-8,2.145268159803889e-10,1.6198043933498568e-10,2.7812295435222917e-10 | ||
fib/5,2.3776579995877364e-7,2.343297169016553e-7,2.4262841729253593e-7,1.3331560091086646e-8,9.007202760821372e-9,1.9969513691856127e-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am slightly confused by the naming. You're using criterion/cabal interchangeably. Which one is the correct one? Additionally, I would suggest adding
haskel-
prefix anyway just to make sure it's more obvious. So eitherhaskell-cabal
orhaskel-criterion