commit 2122c5d537dca7bfca4831c91f8a4188e98a23ed
parent a142587677bc0e08bcf395ed88643fd3521fa3c3
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 18 Jan 2025 22:23:16 +0400
bench: flesh out weigh
Diffstat:
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/bench/Weight.hs b/bench/Weight.hs
@@ -1,12 +1,41 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE PackageImports #-}
+{-# LANGUAGE StandaloneDeriving #-}
module Main where
-import qualified Bitcoin.Prim.Script as S
+import Bitcoin.Prim.Script
+import Control.DeepSeq
import qualified Data.ByteString as BS
+import GHC.Generics
import qualified Weigh as W
+deriving stock instance Generic Script
+instance NFData Script
+
+deriving stock instance Generic Term
+instance NFData Term
+
+deriving stock instance Generic Opcode
+instance NFData Opcode
+
main :: IO ()
main = W.mainWith $ do
- W.func "bs_to_ba" S.bs_to_ba (BS.replicate 1024 0x00)
+ W.func "bs_to_ba" bs_to_ba (BS.replicate 1024 0x00)
+ W.func "ba_to_bs" ba_to_bs ba
+ W.func "to_script" to_script terms
+ W.func "from_script" from_script script
+ where
+ ba = bs_to_ba (BS.replicate 1024 0x00)
+ script = to_script terms
+ terms = [
+ OPCODE OP_DUP,OPCODE OP_HASH160,OPCODE OP_PUSHBYTES_20,BYTE 0x89,BYTE 0xab
+ , BYTE 0xcd,BYTE 0xef,BYTE 0xab,BYTE 0xba,BYTE 0xab,BYTE 0xba,BYTE 0xab
+ , BYTE 0xba,BYTE 0xab,BYTE 0xba,BYTE 0xab,BYTE 0xba,BYTE 0xab,BYTE 0xba
+ , BYTE 0xab,BYTE 0xba,BYTE 0xab,BYTE 0xba,OPCODE OP_EQUALVERIFY
+ , OPCODE OP_CHECKSIG
+ ]
+
diff --git a/ppad-script.cabal b/ppad-script.cabal
@@ -87,6 +87,7 @@ benchmark script-weigh
build-depends:
base
, bytestring
+ , deepseq
, ppad-script
, weigh