1{-# LANGUAGE ConstraintKinds, TypeSynonymInstances, BangPatterns, ScopedTypeVariables, TupleSections, GADTs, RankNTypes, FlexibleInstances, FlexibleContexts, MultiParamTypeClasses, GeneralizedNewtypeDeriving #-}
2{-# OPTIONS_GHC -fno-warn-orphans #-}
10import Reflex.Host.Class
13import Reflex.Plan.Reflex
15import Reflex.Spider.Internal (SpiderEventHandle)
16import qualified Reflex.Bench.Focused as Focused
18import Control.Applicative
19import Control.DeepSeq (NFData (..))
25type MonadReflexHost' t m = (MonadReflexHost t m, MonadIORef m, MonadIORef (HostFrame t))
28setupFiring :: (MonadReflexHost t m, MonadIORef m) => Plan t (Event t a) -> m (Ignore (EventHandle t a), Schedule t)
34-- Hack to avoid the NFData constraint for EventHandle which is a synonym
35newtype Ignore a = Ignore a
36instance NFData (Ignore a) where
39instance NFData (SpiderEventHandle a) where
42instance NFData (Behavior t a) where
45instance NFData (Firing t) where
46 rnf !(Firing _ _) = ()
48-- Measure the running time
49benchFiring :: (MonadReflexHost' t m, MonadSample t m) => (forall a. m a -> IO a) -> (String, TestCase) -> Benchmark
50benchFiring runHost (name, TestE p) = env setup (\e -> bench name $ whnfIO $ run e) where
51 run (Ignore h, s) = runHost (readSchedule s (readEvent' h)) >> performGC
52 setup = runHost $ setupFiring p
54benchFiring runHost (name, TestB p) = env setup (\e -> bench name $ whnfIO $ run e) where
55 run (b, s) = runHost (readSchedule s (sample b)) >> performGC
58 return (b, makeDense s)
62 hSetBuffering stdout LineBuffering
63 defaultMainWith (defaultConfig { timeLimit = 10, csvFile = Just "dmap-original.csv" })
64 [ benchImpl "spider" runSpiderHost
67benchImpl :: (MonadReflexHost' t m, MonadSample t m) => String -> (forall a. m a -> IO a) -> Benchmark
68benchImpl name runHost = bgroup name [ sub 100 40
78 sub n frames = runGroup ("subscribing " ++ show (n, frames)) $ Focused.subscribing n frames
79 firing n = runGroup ("firing " ++ show n) $ Focused.firing n
80 merging n = runGroup ("merging " ++ show n) $ Focused.merging n
81 dynamics n = runGroup ("dynamics " ++ show n) $ Focused.dynamics n
83 runGroup name' benchmarks = bgroup name' (benchFiring runHost <$> benchmarks)
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