Skip to content

Commit

Permalink
Add weigh
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa McHale committed Mar 19, 2019
1 parent d60ae7e commit 3bd1737
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
26 changes: 25 additions & 1 deletion plutus-core-interpreter/plutus-core-interpreter.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test-suite plutus-core-interpreter-test
if impl(ghc >=8.4)
ghc-options: -Wmissing-export-lists

benchmark language-plutus-core-bench
benchmark plutus-core-interpreter-bench
type: exitcode-stdio-1.0
main-is: Bench.hs
hs-source-dirs: bench
Expand All @@ -117,3 +117,27 @@ benchmark language-plutus-core-bench

if impl(ghc >=8.4)
ghc-options: -Wmissing-export-lists

benchmark plutus-core-interpreter-weigh
type: exitcode-stdio-1.0
main-is: Bench.hs
hs-source-dirs: weigh
default-language: Haskell2010
ghc-options: -Wall -Wincomplete-uni-patterns
-Wincomplete-record-updates -Wredundant-constraints -Widentities
-rtsopts
build-depends:
base -any,
language-plutus-core -any,
plutus-core-interpreter -any,
weigh -any,
bytestring -any

if flag(eventlog)
ghc-options: -eventlog

if flag(development)
ghc-options: -Werror

if impl(ghc >=8.4)
ghc-options: -Wmissing-export-lists
24 changes: 24 additions & 0 deletions plutus-core-interpreter/weigh/Bench.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Main (main) where

import Control.Monad (void)
import qualified Data.ByteString.Lazy as BSL
import Language.PlutusCore
import Language.PlutusCore.Interpreter.CekMachine (runCek)
import Weigh

main :: IO ()
main = do
~(f, g) <- evalFiles
let processor :: BSL.ByteString -> Either (Error AlexPosn) (Program TyName Name ())
processor contents = void <$> (runQuoteT $ parseScoped contents)
f' = processor f
g' = processor g

mainWith $ sequence_
[ func "valid" (fmap (runCek mempty)) f'
, func "valid" (fmap (runCek mempty)) g'
]

where evalFile0 = BSL.readFile "../language-plutus-core/test/Evaluation/Golden/verifySignature.plc"
evalFile1 = BSL.readFile "../language-plutus-core/test/Evaluation/Golden/verifySignatureError.plc"
evalFiles = (,) <$> evalFile0 <*> evalFile1

0 comments on commit 3bd1737

Please sign in to comment.