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
|
module Main where
|
||||||
|
|
||||||
import Criterion.Main
|
import Criterion.Main
|
||||||
|
import Data.String
|
||||||
import Prologue
|
import Prologue
|
||||||
|
import Test.QuickCheck
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain
|
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
|
hs-source-dirs: bench
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, criterion
|
, criterion
|
||||||
|
, QuickCheck >= 2.8.1
|
||||||
, semantic-diff
|
, semantic-diff
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N -j -O2 -static
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N -j -O2 -static
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
Loading…
Reference in New Issue
Block a user