diff options
author | Marvin Borner | 2023-03-09 12:59:45 +0100 |
---|---|---|
committer | Marvin Borner | 2023-03-09 14:15:25 +0100 |
commit | ccda56bb092db65e13d44e8171bbd85815fcd08d (patch) | |
tree | 833cad2ef894cd7394b81386ef70cd207ebc0ef7 /src/Eval.hs | |
parent | c5854dcadd28f4584930649ba0da49e84d2cde87 (diff) |
Added deepseq for better timing (no overhead)
Diffstat (limited to 'src/Eval.hs')
-rw-r--r-- | src/Eval.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Eval.hs b/src/Eval.hs index c91329c..3ee762f 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -5,6 +5,7 @@ module Eval import Binary import Control.Concurrent +import Control.DeepSeq ( deepseq ) import Control.Exception import Control.Monad.State import qualified Control.Monad.State.Strict as StrictState @@ -266,10 +267,12 @@ evalCommand inp s@(EnvState env@(Environment envDefs) conf cache) = \case pure $ EnvState (Environment M.empty) conf (EnvCache M.empty) Time e -> do start <- getTime Monotonic - _ <- evalInstruction (ContextualInstruction (Evaluate e) inp) - s - (const $ pure s) - end <- getTime Monotonic + let (res, _) = evalExp e (Environment M.empty) `runState` env + end <- case res of + Left err -> print err >> getTime Monotonic + Right e' -> do + red <- reduce e' + deepseq red (getTime Monotonic) let roundSecs x = (fromIntegral (round $ x * 1e6 :: Integer)) / 1e6 :: Double putStr |