mirror of
https://github.com/ilyakooo0/streamly.git
synced 2024-10-06 05:07:07 +03:00
Move rate test to examples
This commit is contained in:
parent
48b21f731b
commit
1691aa3ed1
11
examples/Rate.hs
Normal file
11
examples/Rate.hs
Normal file
@ -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")
|
@ -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
|
||||
|
@ -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"
|
Loading…
Reference in New Issue
Block a user