Skip to content

Commit

Permalink
Add more logging and a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
thealmarty committed Sep 16, 2021
1 parent d38d3d6 commit 883b93e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
@@ -1,10 +1,8 @@
-- | The API to the CEK machine.

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

module UntypedPlutusCore.Evaluation.Machine.Cek
(
Expand Down Expand Up @@ -115,7 +113,7 @@ evaluateCek
-> (Either (CekEvaluationException uni fun) (Term Name uni fun ()), [Text])
evaluateCek emitMode params term =
case runCek params restrictingEnormous emitMode term of
(errOrRes, _, logs) -> (errOrRes, "testing evaluateCek log empty" : logs)
(errOrRes, _, logs) -> (errOrRes, logs)

-- | Evaluate a term using the CEK machine with logging disabled.
evaluateCekNoEmit
Expand Down
13 changes: 9 additions & 4 deletions plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs
Expand Up @@ -404,13 +404,18 @@ hoistExpr var t =
(PIR.Def var' (PIR.mkVar () var', PIR.Strict))
mempty

-- CompileContext {ccOpts=profileOpts} <- ask
CompileContext {ccOpts=profileOpts} <- ask
t' <- do
if coProfile profileOpts==All then do
let ty = PLC.varDeclType var'
-- if coProfile profileOpts==All then do
t'' <- compileExpr t
return $ mkTrace ty "entering" ((\() -> mkTrace ty "exiting" t'') ())
-- else compileExpr t
let tInText = T.pack (show t'')
return $
mkTrace
ty
("entering" <> tInText)
((\() -> mkTrace ty ("exiting"<> tInText) t'') ())
else compileExpr t

-- See Note [Non-strict let-bindings]
let strict = PIR.isPure (const PIR.NonStrict) t'
Expand Down
3 changes: 2 additions & 1 deletion plutus-tx-plugin/test/Plugin/Profiling.hs
Expand Up @@ -29,7 +29,7 @@ import Data.Text (Text)

profiling :: TestNested
profiling = testNested "Profiling" [
goldenPir "fib" fibTest
goldenUEvalProfile "fib4" [ toUPlc fibTest, toUPlc $ plc (Proxy @"4") (4::Integer) ]
]

fib :: Integer -> Integer
Expand All @@ -42,3 +42,4 @@ fib n = if Builtins.equalsInteger n 0
fibTest :: CompiledCode (Integer -> Integer)
-- not using case to avoid literal cases
fibTest = plc (Proxy @"fib") fib

0 comments on commit 883b93e

Please sign in to comment.