File tree Expand file tree Collapse file tree 2 files changed +33
-18
lines changed
Expand file tree Collapse file tree 2 files changed +33
-18
lines changed Original file line number Diff line number Diff line change @@ -37,20 +37,13 @@ open import System.Clock.Primitive as Prim
3737 -- System-wide monotonic time since an arbitrary point in the past
3838 ; monotonic
3939 -- System-wide real time since the Epoch
40- ; realTime
40+ ; realtime
4141 -- Amount of execution time of the current process
4242 ; processCPUTime
4343 -- Amount of execution time of the current OS thread
4444 ; threadCPUTime
4545 -- A raw hardware version of Monotonic ignoring adjustments
4646 ; monotonicRaw
47- -- Linux-specific clocks
48- -- Similar to Monotonic, includes time spent suspended
49- ; bootTime
50- -- Faster but less precise alternative to Monotonic
51- ; monotonicCoarse
52- -- Faster but less precise alternative to RealTime
53- ; realTimeCoarse
5447 )
5548
5649------------------------------------------------------------------------
@@ -86,9 +79,9 @@ record Timed (A : Set a) : Set a where
8679
8780time : IO A → IO (Timed A)
8881time io = do
89- start ← lift! $ getTime realTime
82+ start ← lift! $ getTime realtime
9083 a ← io
91- end ← lift! $ getTime realTime
84+ end ← lift! $ getTime realtime
9285 pure $ mkTimed a $ diff (lower start) (lower end)
9386
9487time′ : IO {0ℓ} A → IO Time
Original file line number Diff line number Diff line change @@ -13,17 +13,39 @@ open import IO.Primitive using (IO)
1313open import Foreign.Haskell using (Pair)
1414
1515data Clock : Set where
16- monotonic realTime processCPUTime : Clock
17- threadCPUTime monotonicRaw bootTime : Clock
18- monotonicCoarse realTimeCoarse : Clock
16+ monotonic realtime processCPUTime : Clock
17+ threadCPUTime monotonicRaw : Clock
1918
20- {-# COMPILE GHC Clock = data Clock (Monotonic | Realtime | ProcessCPUTime
21- | ThreadCPUTime | MonotonicRaw | Boottime
22- | MonotonicCoarse | RealtimeCoarse )
19+ {-# FOREIGN GHC import System.Clock #-}
20+
21+ {-# FOREIGN GHC
22+ data AgdaClock
23+ = AgdaMonotonic
24+ | AgdaRealtime
25+ | AgdaProcessCPUTime
26+ | AgdaThreadCPUTime
27+ | AgdaMonotonicRaw
28+
29+ fromAgdaClock :: AgdaClock -> Clock
30+ fromAgdaClock ac = case ac of
31+ AgdaMonotonic -> Monotonic
32+ AgdaRealtime -> Realtime
33+ AgdaProcessCPUTime -> ProcessCPUTime
34+ AgdaThreadCPUTime -> ThreadCPUTime
35+ AgdaMonotonicRaw -> MonotonicRaw
36+ #-}
37+
38+ {-# COMPILE GHC Clock =
39+ data AgdaClock
40+ ( AgdaMonotonic
41+ | AgdaRealtime
42+ | AgdaProcessCPUTime
43+ | AgdaThreadCPUTime
44+ | AgdaMonotonicRaw
45+ )
2346#-}
2447
2548postulate getTime : Clock → IO (Pair Nat Nat)
2649
27- {-# FOREIGN GHC import System.Clock #-}
2850{-# FOREIGN GHC import Data.Function #-}
29- {-# COMPILE GHC getTime = fmap (\ (TimeSpec a b) -> ((,) `on` fromIntegral) a b) . getTime #-}
51+ {-# COMPILE GHC getTime = fmap (\ (TimeSpec a b) -> ((,) `on` fromIntegral) a b) . getTime . fromAgdaClock #-}
You can’t perform that action at this time.
0 commit comments