format everything with hindent
[packages/time.git] / benchmark / Main.hs
1 {-# LANGUAGE PackageImports #-}
2
3 module Main where
4
5 import Criterion.Main
6 import Data.Time
7 import Data.Time.Clock.POSIX
8 import Data.Time.Clock.System
9
10 import qualified "time" Data.Time as O
11 import qualified "time" Data.Time.Clock.POSIX as O
12
13 main :: IO ()
14 main = do
15 getCurrentTime >>= print
16 O.getCurrentTime >>= print
17 getPOSIXTime >>= print . posixSecondsToUTCTime
18 O.getPOSIXTime >>= print . O.posixSecondsToUTCTime
19 getZonedTime >>= print
20 O.getZonedTime >>= print
21 _tz <- getCurrentTimeZone
22 ct <- getCurrentTime
23 _otz <- O.getCurrentTimeZone
24 oct <- O.getCurrentTime
25 defaultMain
26 [ bgroup "getCurrentTime" [bench "old" $ nfIO O.getCurrentTime, bench "new" $ nfIO getCurrentTime]
27 , bgroup "getPOSIXTime" [bench "old" $ nfIO O.getPOSIXTime, bench "new" $ nfIO getPOSIXTime]
28 , bgroup "getSystemTime" [bench "new" $ nfIO getSystemTime]
29 , bgroup "getTimeZone" [bench "old" $ nfIO $ O.getTimeZone oct, bench "new" $ nfIO $ getTimeZone ct]
30 , bgroup "getCurrentTimeZone" [bench "old" $ nfIO O.getCurrentTimeZone, bench "new" $ nfIO getCurrentTimeZone]
31 , bgroup "getZonedTime" [bench "old" $ nfIO O.getZonedTime, bench "new" $ nfIO getZonedTime]
32 , bgroup
33 "formatTime"
34 [ bench "old" $ nf (O.formatTime O.defaultTimeLocale "%a, %_d %b %Y %H:%M:%S %Z") oct
35 , bench "new" $ nf (formatTime defaultTimeLocale "%a, %_d %b %Y %H:%M:%S %Z") ct
36 ]
37 ]