Skip to content

Commit

Permalink
Remove old applyMerge benchmarking code
Browse files Browse the repository at this point in the history
  • Loading branch information
pgujjula committed May 10, 2024
1 parent a7860a1 commit b1c0de9
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,17 @@

module Main (main) where

import ApplyMerge.DoublyLinkedList qualified
import ApplyMerge.IntMap qualified
import ApplyMerge.IntSet qualified
import ApplyMerge.MergeAll qualified
import Bench.ApplyMerge qualified
import Bench.Data.DoublyLinkedList.STRef qualified
import Bench.PriorityQueue.MinPQueue qualified
import Bench.PriorityQueue.MinPQueue.Mutable qualified
import Data.Function ((&))
import Test.Tasty.Bench (Benchmark, bench, bgroup, defaultMain, nf)
import Test.Tasty.Bench (defaultMain)

main :: IO ()
main =
defaultMain
[ benchCommon
"DoublyLinkedList"
ApplyMerge.DoublyLinkedList.applyMerge,
benchCommon "IntMap" ApplyMerge.IntMap.applyMerge,
benchCommon "IntSet" ApplyMerge.IntSet.applyMerge,
benchCommon "MergeAll" ApplyMerge.MergeAll.applyMerge,
Bench.ApplyMerge.benchmarks,
[ Bench.ApplyMerge.benchmarks,
Bench.Data.DoublyLinkedList.STRef.benchmarks,
Bench.PriorityQueue.MinPQueue.benchmarks,
Bench.PriorityQueue.MinPQueue.Mutable.benchmarks
]

benchCommon ::
String ->
(forall a b c. (Ord c) => (a -> b -> c) -> [a] -> [b] -> [c]) ->
Benchmark
benchCommon name applyMerge =
bgroup name [benchmarkSymmetric]
where
benchmarkSymmetric :: Benchmark
benchmarkSymmetric =
bgroup "benchmarkSymmetric" (fmap mkBench [1 .. (6 :: Int)])
where
mkBench :: Int -> Benchmark
mkBench i = bench (show i) (nf collapse (10 ^ i))
where
collapse :: Int -> Int
collapse n =
let start = (n `quot` maxBound) + 1
in applyMerge (*) [start ..] [start ..]
& take n
& sum

0 comments on commit b1c0de9

Please sign in to comment.