1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE ExplicitNamespaces #-}
3{-# LANGUAGE KindSignatures #-}
4{-# LANGUAGE PolyKinds #-}
5{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE TypeOperators #-}
7{-# LANGUAGE UndecidableInstances #-}
9{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
15import Criterion.Main (Benchmark, bench, bgroup, nf)
17import Prelude hiding (lookup)
19import Data.Maybe (fromJust)
20import Data.Proxy (Proxy (..))
21import Data.Typeable (Typeable)
24import Data.TypeRepMap.Internal (TF (..), TypeRepMap (..), fromList, lookup)
26benchCacheMap :: Benchmark
27benchCacheMap = bgroup "vector optimal cache"
28 [ bench "lookup" $ nf tenLookups bigMap
29 -- , bench "insert new" $ whnf (\x -> rknf $ insert x bigMap) (Proxy :: Proxy 9999999999)
30 -- , bench "update old" $ whnf (\x -> rknf $ insert x bigMap) (Proxy :: Proxy 1)
33tenLookups :: TypeRepMap (Proxy :: Nat -> *)
34 -> ( Proxy 10, Proxy 20, Proxy 30, Proxy 40
35 , Proxy 50, Proxy 60, Proxy 70, Proxy 80
37tenLookups tmap = (lp, lp, lp, lp, lp, lp, lp, lp)
39 lp :: forall (a::Nat). Typeable a => Proxy a
40 lp = fromJust $ lookup tmap
42-- TypeRepMap of 10000 elements
43bigMap :: TypeRepMap (Proxy :: Nat -> *)
44bigMap = fromList $ buildBigMap 10000 (Proxy :: Proxy 0) []
46buildBigMap :: forall a . (KnownNat a)
49 -> [TF (Proxy :: Nat -> *)]
50 -> [TF (Proxy :: Nat -> *)]
51buildBigMap 1 x = (TF x :)
52buildBigMap n x = (TF x :) . buildBigMap (n - 1) (Proxy :: Proxy (a + 1))
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