1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

Add a function to produce generative benchmarks.

This commit is contained in:
Rob Rix 2016-05-31 10:37:34 -04:00
parent 275751b0c5
commit 7a3cfd3425
2 changed files with 12 additions and 0 deletions

View File

@ -1,8 +1,19 @@
module Main where
import Criterion.Main
import Data.String
import Prologue
import Test.QuickCheck
main :: IO ()
main = defaultMain
[]
arbitraryBenchmark :: (Arbitrary a, Show m) => String -> (a -> m) -> Benchmarkable -> IO Benchmark
arbitraryBenchmark name metric benchmark = do
benchmarks <- traverse measure [0..100]
pure $! bgroup name benchmarks
where measure n = do
input <- generate (resize n arbitrary)
let measurement = metric input
pure $! bench (show measurement) benchmark

View File

@ -72,6 +72,7 @@ benchmark semantic-diff-bench
hs-source-dirs: bench
build-depends: base
, criterion
, QuickCheck >= 2.8.1
, semantic-diff
ghc-options: -threaded -rtsopts -with-rtsopts=-N -j -O2 -static
default-language: Haskell2010