diff options
Diffstat (limited to 'bench/main.hs')
-rw-r--r-- | bench/main.hs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/bench/main.hs b/bench/main.hs index f8db78c..10639eb 100644 --- a/bench/main.hs +++ b/bench/main.hs @@ -1,12 +1,14 @@ module Main (main) where +import Data.IORef (newIORef) +import Data.Time import Gauge import Xmobar import Xmobar.Plugins.Monitors.Cpu main :: IO () main = do - defaultMain =<< sequence [cpuBench] + defaultMain =<< sequence [cpuBench, dateBench] mkCpuArgs :: IO CpuArguments mkCpuArgs = getArguments ["-L", "3", "-H", "50", "--normal", "green", "--high", "red", "-t", "Cpu: <total>%"] @@ -17,3 +19,21 @@ cpuBench = do return $ bgroup "Cpu Benchmarks" [ bench "CPU normal args" $ nfIO (runCpu cpuArgs) ] + +dateBench :: IO Benchmark +dateBench = do + let format = "D: %B %d %A W%V" + zone <- getCurrentTimeZone + zone' <- newIORef =<< getCurrentTimeZone + return $ bgroup "Date Benchmarks" + [ bench "Date" $ nfIO (date zone' format) + , bench "DateZonedTime" $ nfIO (dateZonedTime format) + , bench "DateWithTimeZone" $ nfIO (dateWithTimeZone zone format) + ] + +dateZonedTime :: String -> IO String +dateZonedTime format = fmap (formatTime defaultTimeLocale format) getZonedTime + +dateWithTimeZone :: TimeZone -> String -> IO String +dateWithTimeZone zone format = + fmap (formatTime defaultTimeLocale format . utcToZonedTime zone) getCurrentTime |