ekg/examples/Basic.hs

28 lines
733 B
Haskell
Raw Normal View History

2011-12-29 19:45:47 +00:00
{-# LANGUAGE OverloadedStrings #-}
-- | Example program that continously computes the mean of a list of
-- numbers.
module Main where
import Control.Concurrent
import Control.Exception
import qualified System.Remote.Counter as Counter
2012-04-18 02:06:32 +00:00
import qualified System.Remote.Label as Label
2011-12-29 19:45:47 +00:00
import System.Remote.Monitoring
mean :: Fractional a => [a] -> a
mean xs = sum xs / fromIntegral (length xs)
main :: IO ()
main = do
handle <- forkServer "localhost" 8000
counter <- getCounter "iterations" handle
2012-04-18 02:06:32 +00:00
label <- getLabel "args" handle
Label.set label "some text string"
2011-12-29 19:45:47 +00:00
let loop n = do
evaluate $ mean [1..n]
threadDelay 2000
Counter.inc counter
loop n
loop 1000000