File: Main.hs

package info (click to toggle)
haskell-psqueues 0.2.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: haskell: 2,599; makefile: 4
file content (49 lines) | stat: -rw-r--r-- 1,741 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{-# LANGUAGE BangPatterns #-}
module Main where

import           Criterion.Main
import           System.Random

import           BenchmarkTypes

import qualified Data.OrdPSQ.Benchmark              as OrdPSQ
import qualified Data.IntPSQ.Benchmark              as IntPSQ
import qualified Data.HashPSQ.Benchmark             as HashPSQ
import qualified Data.PSQueue.Benchmark             as PSQueue

benchmarkSize :: Int
benchmarkSize = 2 ^ (12 :: Int)

{-# NOINLINE increasing #-}
increasing :: [BElem]
increasing = [(n, n, ()) | n <- [1 .. benchmarkSize]]

{-# NOINLINE decreasing #-}
decreasing :: [BElem]
decreasing = reverse increasing

{-# NOINLINE semirandom #-}
semirandom :: [BElem]
semirandom =
    [ (x, y, ())
    | (_, x, y) <- zip3 [1 .. benchmarkSize] (randoms gen1) (randoms gen2)
    ]
  where
    gen1 = mkStdGen 1234
    gen2 = mkStdGen 5678

main :: IO ()
main = defaultMain $ runBenchmark
    [ IntPSQ.benchmark    "IntPSQ increasing"             increasing
    , IntPSQ.benchmark    "IntPSQ decreasing"             decreasing
    , IntPSQ.benchmark    "IntPSQ semirandom"             semirandom
    , HashPSQ.benchmark   "HashPSQ increasing"            increasing
    , HashPSQ.benchmark   "HashPSQ decreasing"            decreasing
    , HashPSQ.benchmark   "HashPSQ semirandom"            semirandom
    , OrdPSQ.benchmark    "OrdPSQ increasing"             increasing
    , OrdPSQ.benchmark    "OrdPSQ decreasing"             decreasing
    , OrdPSQ.benchmark    "OrdPSQ semirandom"             semirandom
    , PSQueue.benchmark   "PSQueue increasing"            increasing
    , PSQueue.benchmark   "PSQueue decreasing"            decreasing
    , PSQueue.benchmark   "PSQueue semirandom"            semirandom
    ]