1{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE PolyKinds #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE TypeOperators #-}
8{-# LANGUAGE UndecidableInstances #-}
14import Prelude hiding (lookup)
16import Criterion.Main (bench, env, nf)
17import Data.Kind (Type)
18import Data.Maybe (fromJust)
19import Data.Proxy (Proxy (..))
20import Data.Typeable (Typeable)
21import GHC.TypeLits (type (+), KnownNat, Nat)
23import Data.TypeRep.OptimalVector (TF (..), TypeRepMap (..), fromList, lookup)
25import Spec (BenchSpec (..))
30 { benchLookup = Just $ \name ->
31 env mkBigMap $ \ ~bigMap ->
32 bench name $ nf tenLookups bigMap
33 , benchInsertSmall = Nothing -- Not implemented
34 , benchInsertBig = Nothing -- Not implemented
35 , benchUpdateSmall = Nothing -- Not implemented
36 , benchUpdateBig = Nothing -- Not implemented
40 :: TypeRepMap (Proxy :: Nat -> Type)
41 -> ( Proxy 10, Proxy 20, Proxy 30, Proxy 40
42 , Proxy 50, Proxy 60, Proxy 70, Proxy 80
44tenLookups tmap = (lp, lp, lp, lp, lp, lp, lp, lp)
46 lp :: forall (a::Nat). Typeable a => Proxy a
47 lp = fromJust $ lookup tmap
49-- TypeRepMap of 10000 elements
50mkBigMap :: IO (TypeRepMap (Proxy :: Nat -> Type))
51mkBigMap = pure $ fromList $ buildBigMap 10000 (Proxy :: Proxy 0) []
54 :: forall a . (KnownNat a)
57 -> [TF (Proxy :: Nat -> Type)]
58 -> [TF (Proxy :: Nat -> Type)]
59buildBigMap 1 x = (TF x :)
60buildBigMap 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