summary refs log tree commit diff
path: root/third_party/bazel/rules_haskell/examples/vector/benchmarks/Main.hs
blob: 65bd297a75524f127fe43fe66a9a9f5fed1767cf (plain) (blame)
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
module Main where

import Criterion.Main

import Algo.ListRank  (listRank)
import Algo.Rootfix   (rootfix)
import Algo.Leaffix   (leaffix)
import Algo.AwShCC    (awshcc)
import Algo.HybCC     (hybcc)
import Algo.Quickhull (quickhull)
import Algo.Spectral  ( spectral )
import Algo.Tridiag   ( tridiag )

import TestData.ParenTree ( parenTree )
import TestData.Graph     ( randomGraph )
import TestData.Random    ( randomVector )

import Data.Vector.Unboxed ( Vector )

size :: Int
size = 100000

main = lparens `seq` rparens `seq`
       nodes `seq` edges1 `seq` edges2 `seq`
       do
         as <- randomVector size :: IO (Vector Double)
         bs <- randomVector size :: IO (Vector Double)
         cs <- randomVector size :: IO (Vector Double)
         ds <- randomVector size :: IO (Vector Double)
         sp <- randomVector (floor $ sqrt $ fromIntegral size)
                                 :: IO (Vector Double)
         as `seq` bs `seq` cs `seq` ds `seq` sp `seq`
           defaultMain [ bench "listRank"  $ whnf listRank size
                       , bench "rootfix"   $ whnf rootfix (lparens, rparens)
                       , bench "leaffix"   $ whnf leaffix (lparens, rparens)
                       , bench "awshcc"    $ whnf awshcc (nodes, edges1, edges2)
                       , bench "hybcc"     $ whnf hybcc  (nodes, edges1, edges2)
                       , bench "quickhull" $ whnf quickhull (as,bs)
                       , bench "spectral"  $ whnf spectral sp
                       , bench "tridiag"   $ whnf tridiag (as,bs,cs,ds)
                       ]
  where
    (lparens, rparens) = parenTree size
    (nodes, edges1, edges2) = randomGraph size