sha512

Pure Haskell SHA-256, HMAC-SHA256 (docs.ppad.tech/sha256).
git clone git://git.ppad.tech/sha512.git
Log | Files | Refs | README | LICENSE

commit 3f2458ad5e300bd9354ad2349a5cbac8651ded83
parent db1b8328b4004260706232710e970e02a6b38805
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat,  5 Oct 2024 20:44:40 +0400

bench: add suite

Diffstat:
Mbench/Main.hs | 32+++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/bench/Main.hs b/bench/Main.hs @@ -1,5 +1,35 @@ +{-# LANGUAGE OverloadedStrings #-} module Main where +import Criterion.Main +import qualified Crypto.Hash.SHA512 as SHA512 +import qualified Data.ByteString as BS +import qualified Data.ByteString.Lazy as BL +import qualified Data.Digest.Pure.SHA as SHA + main :: IO () -main = pure () +main = defaultMain [ + suite + ] + +suite :: Benchmark +suite = env setup $ \ ~(bs, bl) -> + bgroup "ppad-sha512" [ + bgroup "SHA512 (32B input)" [ + bench "hash" $ whnf SHA512.hash bs + , bench "hash_lazy" $ whnf SHA512.hash_lazy bl + , bench "SHA.sha512" $ whnf SHA.sha512 bl + ] + , bgroup "HMAC-SHA512 (32B input)" [ + bench "hmac" $ whnf (SHA512.hmac "key") bs + , bench "hmac_lazy" $ whnf (SHA512.hmac_lazy "key") bl + , bench "SHA.hmacSha512" $ whnf (SHA.hmacSha512 "key") bl + ] + ] + where + setup = do + let bs_32B = BS.replicate 32 0 + bl_32B = BL.fromStrict bs_32B + pure (bs_32B, bl_32B) +