-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inline park-bench-internal again, bump some upper bounds
- Loading branch information
1 parent
06a123f
commit e6e61b6
Showing
26 changed files
with
223 additions
and
277 deletions.
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
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,111 @@ | ||
[](https://github.com/awkward-squad/park-bench/actions?query=workflow%3AHaskell-CI) | | ||
[](https://hackage.haskell.org/package/park-bench) | ||
[](https://www.stackage.org/lts/package/park-bench) | ||
[](https://www.stackage.org/nightly/package/park-bench) | ||
[](https://packdeps.haskellers.com/reverse/park-bench) | ||
|
||
# Overview | ||
|
||
`park-bench` is a quick-and-dirty benchmarking tool for comparing the performance of Haskell functions. Specifically, it | ||
is designed to optimize the workflow in which a programmer makes a small change to a function and wants to measure its | ||
performance impact with as little friction as possible. | ||
|
||
 | ||
|
||
# Configuration | ||
|
||
| Environment variable name | Type | Meaning | Default value | | ||
| --- | --- | --- | --- | | ||
| `PARK_BENCH_RUNLEN` | Float | The target number of seconds that each benchmark run takes | `0.1` | | ||
|
||
# Example usage | ||
|
||
Say I am interested in improving the performance of `fib`, which is a function defined in module `MyMathUtilities.Fib` | ||
in a local package called `my-math-utilities`. | ||
|
||
## Step 1: Write the function you'd like to benchmark | ||
|
||
First, I'm going to copy the implementation of `fib` to a new top-level definition called `fastfib`, tweak its | ||
implementation, and export both from module `MyMathUtilities.Fib`. | ||
|
||
If `fib` was private before, that's ok. We only need to expose it for as long as we are interested in benchmarking. | ||
|
||
```haskell | ||
module MyMathUtilities.Fib (fib, fastfib, ...) where | ||
``` | ||
|
||
## Step 2: Write a standalone `bench/Main.hs` module with a `main` function | ||
|
||
Next, I'm going to write a standalone `Main.hs` in a subdirectory called `bench`, which will be compiled to an | ||
executable that runs my benchmark. | ||
|
||
```haskell | ||
module Main where | ||
|
||
-- The module in my local package that I want to benchmark | ||
import MyMathUtilities.Fib | ||
|
||
-- This library | ||
import ParkBench | ||
|
||
main :: IO () | ||
main = | ||
benchmark | ||
[ function "fib" fib 20 | ||
, function "fastfib" fastfib 20 | ||
] | ||
``` | ||
|
||
## Step 3: Define an executable component | ||
|
||
Next, I'm going to define an executable component for my benchmark in my `my-math-utilities.cabal` file. | ||
|
||
```cabal | ||
executable bench | ||
build-depends: | ||
base, | ||
-- The local package that I want to benchmark | ||
my-math-utilities, | ||
-- This library | ||
park-bench | ||
default-language: Haskell2010 | ||
ghc-options: -O -rtsopts -with-rtsopts=-T | ||
hs-source-dirs: bench | ||
main-is: Main.hs | ||
``` | ||
|
||
I need to compile the benchmark with `-rtsopts -with-rtsopts=-T`, otherwise my benchmark will not be able to get RTS | ||
statistics from GHC at runtime. | ||
|
||
Alternatively, I could compile the benchmark with only `-rtsopts`, but then I'll have to provide `+RTS -T` to the | ||
executable later. | ||
|
||
## Step 4: Run the benchmark | ||
|
||
If all goes well, I'll have an executable component to run. | ||
|
||
``` | ||
cabal run my-math-utilities:exe:bench | ||
``` | ||
``` | ||
stack run my-math-utilities:exe:bench | ||
``` | ||
|
||
Or, if I only compiled with `-rtsopts`, but not `-with-rtsopts=-T`, | ||
|
||
``` | ||
cabal run my-math-utilities:exe:bench -- +RTS -T | ||
``` | ||
``` | ||
stack run my-math-utilities:exe:bench -- +RTS -T | ||
``` | ||
|
||
## Step 5: Clean up | ||
|
||
After benchmarking, I can choose to keep the benchmark (and associated executable component) around, but I'll probably | ||
delete them instead. I've learned something, collected some sweet screenshots for my PR, and I'm ready to move on. | ||
|
||
# Caveat emptor | ||
|
||
The statistical analysis performed by `park-bench` is simplistic, written by a novice, and may have bugs. Results should | ||
not necessarily be trusted; please use (or at least compare to) a different tool. |
This file was deleted.
Oops, something went wrong.
File renamed without changes
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,22 +3,26 @@ cabal-version: 2.2 | |
author: Mitchell Rosen, Travis Staton | ||
bug-reports: https://github.com/awkward-squad/park-bench/issues | ||
category: Benchmarking | ||
copyright: Copyright (C) 2020-2022 Mitchell Rosen, Travis Staton | ||
copyright: Copyright (C) 2020-2023 Mitchell Rosen, Travis Staton | ||
homepage: https://github.com/awkward-squad/park-bench | ||
license: BSD-3-Clause | ||
license-file: LICENSE | ||
maintainer: Mitchell Rosen <[email protected]>, Travis Staton <[email protected]> | ||
name: park-bench-internal | ||
name: park-bench | ||
stability: experimental | ||
synopsis: @park-bench@ internals | ||
tested-with: GHC == 9.2.7, GHC == 9.4.4, GHC == 9.6.1 | ||
version: 0.1.0 | ||
synopsis: A quick-and-dirty, low-friction benchmark tool with immediate feedback | ||
tested-with: GHC == 9.4.7, GHC == 9.6.3, GHC == 9.8.1 | ||
version: 0.1.1.0 | ||
|
||
description: | ||
@park-bench@ internals. | ||
A quick-and-dirty, low-friction benchmark tool with immediate feedback. | ||
|
||
extra-doc-files: | ||
images/*.png | ||
|
||
extra-source-files: | ||
CHANGELOG.md | ||
README.md | ||
|
||
source-repository head | ||
type: git | ||
|
@@ -27,10 +31,10 @@ source-repository head | |
library | ||
build-depends: | ||
array ^>= 0.5, | ||
base ^>= 4.12 || ^>= 4.13 || ^>= 4.14 || ^>= 4.15 || ^>= 4.16 || ^>= 4.17 || ^>= 4.18, | ||
bytestring ^>= 0.10 || ^>= 0.11, | ||
ghc-prim ^>= 0.3 || ^>= 0.4 || ^>= 0.5 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 || ^>= 0.10, | ||
text ^>= 1.1 || ^>= 1.2 || ^>= 2.0, | ||
base ^>= 4.12 || ^>= 4.13 || ^>= 4.14 || ^>= 4.15 || ^>= 4.16 || ^>= 4.17 || ^>= 4.18 || ^>= 4.19, | ||
bytestring ^>= 0.10 || ^>= 0.11 || ^>= 0.12, | ||
ghc-prim ^>= 0.3 || ^>= 0.4 || ^>= 0.5 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 || ^>= 0.10 || ^>= 0.11, | ||
text ^>= 1.1 || ^>= 1.2 || ^>= 2.0 || ^>= 2.1, | ||
default-extensions: | ||
AllowAmbiguousTypes | ||
BangPatterns | ||
|
@@ -64,19 +68,7 @@ library | |
ViewPatterns | ||
default-language: Haskell2010 | ||
exposed-modules: | ||
ParkBench.Internal.Array1 | ||
ParkBench.Internal.Benchable | ||
ParkBench.Internal.Builder | ||
ParkBench.Internal.Config | ||
ParkBench.Internal.Driver | ||
ParkBench.Internal.Measure | ||
ParkBench.Internal.Named | ||
ParkBench.Internal.Prelude | ||
ParkBench.Internal.Pretty | ||
ParkBench.Internal.Render | ||
ParkBench.Internal.RtsStats | ||
ParkBench.Internal.Statistics | ||
ParkBench.Internal.Terminal | ||
ParkBench | ||
ghc-options: | ||
-Weverything | ||
-Wno-all-missed-specialisations | ||
|
@@ -92,6 +84,22 @@ library | |
if impl(ghc >= 9.2) | ||
ghc-options: | ||
-Wno-missing-kind-signatures | ||
if impl(ghc >= 9.8) | ||
ghc-options: | ||
-Wno-missing-role-annotations | ||
hs-source-dirs: src | ||
other-modules: | ||
ParkBench.Internal.Array1 | ||
ParkBench.Internal.Benchable | ||
ParkBench.Internal.Benchable.Internal | ||
ParkBench.Internal.Builder | ||
ParkBench.Internal.Config | ||
ParkBench.Internal.Driver | ||
ParkBench.Internal.Measure | ||
ParkBench.Internal.Named | ||
ParkBench.Internal.Prelude | ||
ParkBench.Internal.Pretty | ||
ParkBench.Internal.Render | ||
ParkBench.Internal.RtsStats | ||
ParkBench.Internal.Statistics | ||
ParkBench.Internal.Terminal |
Oops, something went wrong.