diff options
author | Marvin Borner | 2023-02-23 14:59:34 +0100 |
---|---|---|
committer | Marvin Borner | 2023-02-23 14:59:34 +0100 |
commit | 99d8f364d6376886dd49a51ff4c3afe13337cfc4 (patch) | |
tree | 6952df5babd0fbdf282978d91248e3ef93ffa140 /src/Eval.hs | |
parent | 2940495ac437a23084383567be6b3bef9ee9fb8d (diff) |
Added time instruction
Diffstat (limited to 'src/Eval.hs')
-rw-r--r-- | src/Eval.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Eval.hs b/src/Eval.hs index 276524c..331ab8d 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -17,6 +17,7 @@ import Helper import Parser import Paths_bruijn import Reducer +import System.Clock import System.Console.Haskeline import System.Directory import System.Environment @@ -284,6 +285,19 @@ evalInstruction (ContextualInstruction instr inp) s@(EnvState env conf _) rec = yeet s' (c : cs') = do s'' <- s' yeet (evalCommand inp s'' c) cs' + Time e -> do + start <- getTime Monotonic + _ <- evalInstruction (ContextualInstruction (Evaluate e) inp) s rec + end <- getTime Monotonic + let roundSecs x = + (fromIntegral (round $ x * 1e6 :: Integer)) / 1e6 :: Double + putStr + $ show + $ roundSecs + $ (fromIntegral $ toNanoSecs $ diffTimeSpec start end :: Double) + / 1e9 + putStrLn " seconds" + rec s _ -> rec s evalInstruction instr s rec = evalInstruction (ContextualInstruction instr "<unknown>") s rec |