packages feed

benign-timestats-0.1.0: src/Benign/TimeStats.hs

{-# LANGUAGE GHC2021 #-}

module Benign.TimeStats where

import Benign qualified
import Control.Exception
import Debug.TimeStats qualified as TimeStats
import System.IO.Unsafe (unsafePerformIO)

-- | @'measure' label strat thing@ measures, in the style of
-- 'TimeStats.measurePure', of running @strat thing@.
measure :: String -> Benign.Strat a -> a -> a
measure label strat thing = unsafePerformIO $ TimeStats.measureM label $ do Benign.E <- evaluate (strat thing); return thing
{-# NOINLINE measure #-}