commit 9c2f0b9f69d7a17f52409eb7f9cfbb8a4f190659
parent 4af139bc24bf326c6bf3dc7488f0298b887bb4bc
Author: Jared Tobin <jared@jtobin.io>
Date: Wed, 18 Dec 2024 08:21:43 -0330
bench: basic
Diffstat:
2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/bench/Main.hs b/bench/Main.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Main where
+
+import Criterion.Main
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base58 as B58
+import qualified Data.ByteString.Base58Check as B58C
+
+main :: IO ()
+main = defaultMain [
+ base32
+ ]
+
+base32 :: Benchmark
+base32 = bgroup "ppad-base32" [
+ bgroup "base58" [
+ bgroup "encode" [
+ bench "hello world" $ nf B58.encode "hello world"
+ ]
+ , bgroup "decode" [
+ bench "StV1DL6CwTryKyV" $ nf B58.decode "StV1DL6CwTryKyV"
+ ]
+ ]
+ , bgroup "base58check" [
+ bgroup "encode" [
+ bench "0x00, hello world" $ nf (B58C.encode 0x00) "hello world"
+ ]
+ , bgroup "decode" [
+ bench "13vQB7B6MrGQZaxCqW9KER" $
+ nf B58C.decode "13vQB7B6MrGQZaxCqW9KER"
+ ]
+ ]
+ ]
diff --git a/ppad-base58.cabal b/ppad-base58.cabal
@@ -29,3 +29,19 @@ library
base >= 4.9 && < 5
, bytestring >= 0.9 && < 0.13
, ppad-sha256 > 0.2 && < 0.3
+
+benchmark base58-bench
+ type: exitcode-stdio-1.0
+ default-language: Haskell2010
+ hs-source-dirs: bench
+ main-is: Main.hs
+
+ ghc-options:
+ -rtsopts -O2 -Wall
+
+ build-depends:
+ base
+ , bytestring
+ , criterion
+ , ppad-base58
+