Measuring Time - lambda-land/VDBMS GitHub Wiki

Timing Computation

The method coms from:

The approach used for computing timing is referenced from Timing conputations

How to use it:

  1. add dependency clock and import following module:
import System.Directory
import System.Clock
import System.CPUTime
import Text.Printf
  1. include function time in file
time :: IO t -> IO t
time a = do
    start <- getCPUTime
    v <- a
    end   <- getCPUTime
    let diff = (fromIntegral (end - start)) / (10^12)
    printf "Computation time: %0.5f sec\n" (diff :: Double)
    return v
  • You can change 0.5 to any number you like.
  1. use time to mesuareg the function execution time
main = do 
       putStrLn "Starting..."
       time $ runTransFilterUnion vqManual p employeeVDB  `seq` return ()
       putStrLn "Done."