From 1691aa3ed14e22546e85e82ea32828379526bc1a Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Wed, 3 Jun 2020 19:37:12 +0530 Subject: [PATCH] Move rate test to examples --- examples/Rate.hs | 11 +++++++++++ streamly.cabal | 12 ++++++++++++ test/rate-timestamp.hs | 26 -------------------------- 3 files changed, 23 insertions(+), 26 deletions(-) create mode 100644 examples/Rate.hs delete mode 100644 test/rate-timestamp.hs diff --git a/examples/Rate.hs b/examples/Rate.hs new file mode 100644 index 00000000..ab917a88 --- /dev/null +++ b/examples/Rate.hs @@ -0,0 +1,11 @@ +import Streamly +import qualified Streamly.Prelude as S +import qualified Streamly.Internal.Prelude as Internal + +main :: IO () +main = + S.mapM_ print + $ asyncly + $ avgRate 1 + $ Internal.timestamped + $ S.repeatM (pure "tick") diff --git a/streamly.cabal b/streamly.cabal index 845db4c3..769fdebb 100644 --- a/streamly.cabal +++ b/streamly.cabal @@ -864,3 +864,15 @@ executable CamelCase , base >= 4.8 && < 5 else buildable: False + +executable Rate + import: exe-options + main-is: Rate.hs + hs-source-dirs: examples + if (flag(examples) || flag(examples-sdl)) && !impl(ghcjs) + buildable: True + build-Depends: + streamly + , base >= 4.8 && < 5 + else + buildable: False diff --git a/test/rate-timestamp.hs b/test/rate-timestamp.hs deleted file mode 100644 index 9afb79fa..00000000 --- a/test/rate-timestamp.hs +++ /dev/null @@ -1,26 +0,0 @@ -{-# LANGUAGE FlexibleContexts #-} - -import Streamly -import Streamly.Prelude as S -import Control.Monad (when) -import Control.Monad.IO.Class (MonadIO(liftIO)) -import System.Clock - -withTimeStamp msg = do - t <- getTime Monotonic - let ns = toNanoSecs t `mod` 10^11 - putStrLn $ show (fromIntegral ns / 1.0e9) <> " " <> msg - --- acidRain :: MonadAsync m => SerialT m Event -producer = - asyncly - $ avgRate 1 - $ S.repeatM - $ liftIO $ do - withTimeStamp "produced" - return 1 - -main :: IO () -main = runStream $ do - _ <- producer - liftIO $ withTimeStamp "consumed\n"