Move rate test to examples
commit1691aa3ed14e22546e85e82ea32828379526bc1a
authorHarendra Kumar <harendra@composewell.com>
dateWed 3 Jun 2020, 19:37 (6 years ago)
parent48b21f7
examples/Rate.hsnew file+11
@@ -0,0 +1,11 @@
1+import Streamly
2+import qualified Streamly.Prelude as S
3+import qualified Streamly.Internal.Prelude as Internal
4+
5+main :: IO ()
6+main =
7+ S.mapM_ print
8+ $ asyncly
9+ $ avgRate 1
10+ $ Internal.timestamped
11+ $ S.repeatM (pure "tick")
streamly.cabal+12
@@ -864,3 +864,15 @@ executable CamelCase
864864 , base >= 4.8 && < 5
865865 else
866866 buildable: False
867+
868+executable Rate
869+ import: exe-options
870+ main-is: Rate.hs
871+ hs-source-dirs: examples
872+ if (flag(examples) || flag(examples-sdl)) && !impl(ghcjs)
873+ buildable: True
874+ build-Depends:
875+ streamly
876+ , base >= 4.8 && < 5
877+ else
878+ buildable: False
test/rate-timestamp.hsdeleted−26
@@ -1,26 +0,0 @@
1−{-# LANGUAGE FlexibleContexts #-}
2−
3−import Streamly
4−import Streamly.Prelude as S
5−import Control.Monad (when)
6−import Control.Monad.IO.Class (MonadIO(liftIO))
7−import System.Clock
8−
9−withTimeStamp msg = do
10− t <- getTime Monotonic
11− let ns = toNanoSecs t `mod` 10^11
12− putStrLn $ show (fromIntegral ns / 1.0e9) <> " " <> msg
13−
14−-- acidRain :: MonadAsync m => SerialT m Event
15−producer =
16− asyncly
17− $ avgRate 1
18− $ S.repeatM
19− $ liftIO $ do
20− withTimeStamp "produced"
21− return 1
22−
23−main :: IO ()
24−main = runStream $ do
25− _ <- producer
26− liftIO $ withTimeStamp "consumed\n"