Commit 237acbe5 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

Add some benchmarks for RefinablePartition.splitBy

parent 4ce6c13b
......@@ -7,6 +7,7 @@ import qualified MA.Functors.BenchMonoidValued
import qualified MA.Parser.BenchLexer
import qualified Data.List.BenchUtils
import qualified MA.Algorithm.BenchInitialize
import qualified Data.BenchRefinablePartition
main :: IO ()
main = defaultMain
......@@ -15,4 +16,5 @@ main = defaultMain
, MA.Parser.BenchLexer.benchmarks
, Data.List.BenchUtils.benchmarks
, MA.Algorithm.BenchInitialize.benchmarks
, Data.BenchRefinablePartition.benchmarks
]
{-# LANGUAGE FlexibleInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Data.BenchRefinablePartition (benchmarks) where
import Criterion
import Control.Monad.ST
import Control.DeepSeq
import Data.RefinablePartition
benchmarks :: Benchmark
benchmarks = bgroup "Data.RefinablePartition" [benchGroupBy]
benchGroupBy :: Benchmark
benchGroupBy = bgroup
"groupBy"
[ bench "10 states, already sorted"
$ withInit (make 10 1 (const 0)) (\p -> groupBy p 0 id)
, bench "20 states, already sorted"
$ withInit (make 20 1 (const 0)) (\p -> groupBy p 0 id)
, bench "100 states, already sorted"
$ withInit (make 100 1 (const 0)) (\p -> groupBy p 0 id)
, bench "1000 states, already sorted"
$ withInit (make 1000 1 (const 0)) (\p -> groupBy p 0 id)
, bench "10 states, reversed"
$ withInit (make 10 1 (const 0)) (\p -> groupBy p 0 negate)
, bench "20 states, reversed"
$ withInit (make 20 1 (const 0)) (\p -> groupBy p 0 negate)
, bench "100 states, reversed"
$ withInit (make 100 1 (const 0)) (\p -> groupBy p 0 negate)
, bench "1000 states, reversed"
$ withInit (make 1000 1 (const 0)) (\p -> groupBy p 0 negate)
]
instance NFData (RefinablePartition RealWorld) where
rnf p = seq p ()
withInit
:: NFData a
=> ST RealWorld (RefinablePartition RealWorld)
-> (RefinablePartition RealWorld -> ST RealWorld a)
-> Benchmarkable
withInit initialize action = perRunEnv (stToIO initialize) (stToIO . action)
......@@ -198,6 +198,7 @@ benchmark bench
, MA.Parser.BenchLexer
, Data.List.BenchUtils
, MA.Algorithm.BenchInitialize
, Data.BenchRefinablePartition
default-extensions: GADTs
, StandaloneDeriving
, DeriveFunctor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment