mirror of
https://github.com/github/semantic.git
synced 2024-12-18 04:11:48 +03:00
Add a function to produce generative benchmarks.
This commit is contained in:
parent
275751b0c5
commit
7a3cfd3425
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user