-
Notifications
You must be signed in to change notification settings - Fork 1
/
Util.hs
27 lines (21 loc) · 654 Bytes
/
Util.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-# LANGUAGE BangPatterns #-}
module Util where
import Data.Time
import Data.List.Split (splitEvery)
import Conf
timed act = do
putStrLn ""
t0 <- getCurrentTime
!v <- act
t1 <- getCurrentTime
let td = diffUTCTime t1 t0
-- let format = show v -- (show ((fromIntegral v / (10 ** 12)) :: Double))
putStrLn $ "Action time: " ++ show td
return (v,td)
runTest :: (IO ()) -> IO ()
runTest test = do
(_, t) <- timed test
let format x = unwords . reverse . map reverse . splitEvery 3 . reverse . show $ x
val = format (round (fromIntegral iTERATIONS / realToFrac t :: Double) :: Integer)
putStr "OpsPerSecond: "
putStrLn val