1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE ExplicitNamespaces #-}
3{-# LANGUAGE KindSignatures #-}
4{-# LANGUAGE PolyKinds #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE TypeOperators #-}
8{-# LANGUAGE UndecidableInstances #-}
10{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
14 , prepareBenchVectorOpt
17import Criterion.Main (Benchmark, bench, bgroup, nf)
19import Prelude hiding (lookup)
21import Data.Maybe (fromJust)
22import Data.Proxy (Proxy (..))
23import Data.Typeable (Typeable)
26import Data.TypeRep.OptimalVector
28benchVectorOpt :: Benchmark
29benchVectorOpt = bgroup "vector optimal"
30 [ bench "lookup" $ nf tenLookups bigMap
31 -- , bench "insert new" $ whnf (\x -> insert x bigMap) (Proxy :: Proxy 9999999999)
32 -- , bench "update old" $ whnf (\x -> insert x bigMap) (Proxy :: Proxy 1)
35tenLookups :: TypeRepVector (Proxy :: Nat -> *)
36 -> ( Proxy 1000, Proxy 2000, Proxy 3000, Proxy 4000
37 , Proxy 5000, Proxy 6000, Proxy 7000, Proxy 8000
39tenLookups tmap = (lp, lp, lp, lp, lp, lp, lp, lp)
41 lp :: forall (a::Nat). Typeable a => Proxy a
42 lp = fromJust $ lookup tmap
44-- TypeRepMap of 10000 elements
45bigMap :: TypeRepVector (Proxy :: Nat -> *)
46bigMap = fromList $ buildBigMap 10000 (Proxy :: Proxy 0) []
48buildBigMap :: forall a . (Typeable a, KnownNat a) => Int -> Proxy (a :: Nat) -> [TF (Proxy :: Nat -> *)] -> [TF (Proxy :: Nat -> *)]
49buildBigMap 1 x = (TF x :)
50buildBigMap n x = (TF x :) . buildBigMap (n - 1) (Proxy :: Proxy (a + 1))
52prepareBenchVectorOpt :: IO ()
53prepareBenchVectorOpt = return ()
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list