-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathTiming.hs
52 lines (44 loc) · 988 Bytes
/
Timing.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{-# LANGUAGE CPP #-}
{- |
Module : $Header$
Description : utility module for measuring execution time
Copyright : (c) C. Maeder DFKI GmbH
License : GPLv2 or higher, see LICENSE.txt
Maintainer : Christian.Maeder@dfki.de
Stability : provisional
Portability : portable
Utility functions that can't be found in the libraries
but should be shared across Hets.
-}
module Common.Timing where
#ifdef UNIX
import System.Posix.Time
import System.Posix.Types
#else
import Data.Time.Clock
#endif
import Data.Time
import Control.Monad
newtype HetsTime = HetsTime
#ifdef UNIX
EpochTime
#else
UTCTime
#endif
getHetsTime :: IO HetsTime
getHetsTime = liftM HetsTime
#ifdef UNIX
epochTime
#else
getCurrentTime
#endif
diffHetsTime :: HetsTime -> HetsTime -> TimeOfDay
diffHetsTime (HetsTime t1) (HetsTime t2) =
timeToTimeOfDay $ secondsToDiffTime $ round
(realToFrac (
#ifdef UNIX
(-)
#else
diffUTCTime
#endif
t1 t2) :: Double)