bip32

Pure Haskell BIP32 hierarchical deterministic wallets.
git clone git://git.ppad.tech/bip32.git
Log | Files | Refs | README | LICENSE

commit 6829fbdac73cafd5846f489dc72b2b7a72693e47
parent a9d2426ff70b6a84f423c58bf98db2f79fc6b4c0
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat, 22 Feb 2025 14:38:01 +0400

bench: basic suite

Diffstat:
Mbench/Main.hs | 55++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mppad-bip32.cabal | 1+
2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/bench/Main.hs b/bench/Main.hs @@ -1,4 +1,57 @@ +{-# OPTIONS_GHC -fno-warn-orphans #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE StandaloneDeriving #-} + module Main where +import Criterion.Main +import Crypto.HDKey.BIP32 +import Control.DeepSeq +import Crypto.Curve.Secp256k1 as S + +instance NFData S.Projective + +instance NFData XPub where + rnf (XPub (X a b)) = a `deepseq` b `deepseq` () + +instance NFData XPrv where + rnf (XPrv (X a b)) = a `deepseq` b `deepseq` () + +instance NFData HDKey where + rnf (HDKey a b c d) = a `deepseq` b `deepseq` c `deepseq` d `deepseq` () + main :: IO () -main = pure () +main = defaultMain [ + bgroup "ppad-bip32" [ + bench_master + , bench_derive_pub + , bench_derive_priv + , bench_xpub + , bench_xprv + ] + ] + +m :: HDKey +m = case master "my super entropic entropy" of + Just !s -> s + _ -> error "bang" + +bench_master :: Benchmark +bench_master = bench "master" $ nf master "my super entropic entropy" + +bench_derive_pub :: Benchmark +bench_derive_pub = bench "derive_child_pub" $ nf (derive_child_pub m) 0 + +bench_derive_priv :: Benchmark +bench_derive_priv = bench "derive_child_priv" $ nf (derive_child_priv m) 0 + +bench_xpub :: Benchmark +bench_xpub = bench "xpub" $ nf xpub m + +bench_xprv :: Benchmark +bench_xprv = bench "xprv" $ nf xprv m + +bench_parse :: Benchmark +bench_parse = bench "parse" $ nf parse (xprv m) + diff --git a/ppad-bip32.cabal b/ppad-bip32.cabal @@ -70,4 +70,5 @@ benchmark bip32-bench , criterion , deepseq , ppad-bip32 + , ppad-secp256k1