Skip to content

Commit

Permalink
Add CustomTime time mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Lysxia committed Feb 23, 2025
1 parent 2a66522 commit 423fb6a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Test/Tasty/Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,8 @@ data TimeMode = CpuTime
-- ^ Measure CPU time.
| WallTime
-- ^ Measure wall-clock time.
| CustomTime String (IO Word64)
-- ^ Custom measurement action.

#ifdef MIN_VERSION_tasty
instance IsOption RelStDev where
Expand Down Expand Up @@ -922,6 +924,7 @@ instance IsOption TimeMode where
showDefaultValue m = Just $ case m of
CpuTime -> "cpu"
WallTime -> "wall"
CustomTime name _ -> name
#endif

-- | Something that can be benchmarked, produced by 'nf', 'whnf', 'nfIO', 'whnfIO',
Expand Down Expand Up @@ -1101,6 +1104,7 @@ getTimePicoSecs :: TimeMode -> IO Word64
getTimePicoSecs timeMode = case timeMode of
CpuTime -> fromInteger <$> getCPUTime
WallTime -> round . (1e12 *) <$> getWallTimeSecs
CustomTime _ getCustomTime -> getCustomTime

measure :: TimeMode -> Word64 -> Benchmarkable -> IO Measurement
measure timeMode n (Benchmarkable act) = do
Expand Down

0 comments on commit 423fb6a

Please sign in to comment.