|
| 1 | +{-# LANGUAGE BangPatterns #-} |
| 2 | +module Main where |
| 3 | + |
| 4 | +import Bench.Vector.Algo.MutableSet (mutableSet) |
| 5 | +import Bench.Vector.Algo.ListRank (listRank) |
| 6 | +import Bench.Vector.Algo.Rootfix (rootfix) |
| 7 | +import Bench.Vector.Algo.Leaffix (leaffix) |
| 8 | +import Bench.Vector.Algo.AwShCC (awshcc) |
| 9 | +import Bench.Vector.Algo.HybCC (hybcc) |
| 10 | +import Bench.Vector.Algo.Quickhull (quickhull) |
| 11 | +import Bench.Vector.Algo.Spectral (spectral) |
| 12 | +import Bench.Vector.Algo.Tridiag (tridiag) |
| 13 | +import Bench.Vector.Algo.FindIndexR (findIndexR, findIndexR_naive, findIndexR_manual) |
| 14 | + |
| 15 | +import Bench.Vector.TestData.ParenTree (parenTree) |
| 16 | +import Bench.Vector.TestData.Graph (randomGraph) |
| 17 | +import Bench.Vector.Tasty |
| 18 | + |
| 19 | +import Data.Proxy |
| 20 | +import qualified Data.Vector.Mutable as MV |
| 21 | +import qualified Data.Vector.Unboxed as U |
| 22 | +import Data.Word |
| 23 | +import System.Random.Stateful |
| 24 | +import Test.Tasty |
| 25 | +import Test.Tasty.PAPI |
| 26 | +import Test.Tasty.Options |
| 27 | +import Test.Tasty.Runners |
| 28 | + |
| 29 | +indexFindThreshold :: Double |
| 30 | +indexFindThreshold = 2e-5 |
| 31 | + |
| 32 | +main :: IO () |
| 33 | +main = do |
| 34 | + let ourOpts = [Option (Proxy :: Proxy VectorSize), Option (Proxy :: Proxy RandomSeed)] |
| 35 | + ingredients = includingOptions ourOpts : benchIngredients |
| 36 | + opts <- parseOptions ingredients (bench "Fake" (nf id ())) |
| 37 | + let VectorSize useSize = lookupOption opts |
| 38 | + RandomSeed useSeed = lookupOption opts |
| 39 | + |
| 40 | + gen <- newIOGenM (mkStdGen useSeed) |
| 41 | + |
| 42 | + let (!lparens, !rparens) = parenTree useSize |
| 43 | + (!nodes, !edges1, !edges2) <- randomGraph gen useSize |
| 44 | + |
| 45 | + let randomVector l = U.replicateM l (uniformDoublePositive01M gen) |
| 46 | + !as <- randomVector useSize |
| 47 | + !bs <- randomVector useSize |
| 48 | + !cs <- randomVector useSize |
| 49 | + !ds <- randomVector useSize |
| 50 | + !sp <- randomVector (floor $ sqrt $ fromIntegral useSize) |
| 51 | + vi <- MV.new useSize |
| 52 | + |
| 53 | + defaultMainWithIngredients ingredients $ bgroup "All" |
| 54 | + [ bench "listRank" $ whnf listRank useSize |
| 55 | + , bench "rootfix" $ whnf rootfix (lparens, rparens) |
| 56 | + , bench "leaffix" $ whnf leaffix (lparens, rparens) |
| 57 | + , bench "awshcc" $ whnf awshcc (nodes, edges1, edges2) |
| 58 | + , bench "hybcc" $ whnf hybcc (nodes, edges1, edges2) |
| 59 | + , bench "quickhull" $ whnf quickhull (as,bs) |
| 60 | + , bench "spectral" $ whnf spectral sp |
| 61 | + , bench "tridiag" $ whnf tridiag (as,bs,cs,ds) |
| 62 | + , bench "mutableSet" $ nfIO $ mutableSet vi |
| 63 | + , bench "findIndexR" $ whnf findIndexR ((<indexFindThreshold), as) |
| 64 | + , bench "findIndexR_naïve" $ whnf findIndexR_naive ((<indexFindThreshold), as) |
| 65 | + , bench "findIndexR_manual" $ whnf findIndexR_manual ((<indexFindThreshold), as) |
| 66 | + , bench "minimumOn" $ whnf (U.minimumOn (\x -> x*x*x)) as |
| 67 | + , bench "maximumOn" $ whnf (U.maximumOn (\x -> x*x*x)) as |
| 68 | + ] |
0 commit comments