commit 6204475da63aa48a57a36b12ab5c750bc3df9a0b
parent e164102c56450cd502ea8571b553a2d07dc58571
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 10 Jan 2026 15:50:38 +0400
bench: fix weigh
Diffstat:
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/bench/Weight.hs b/bench/Weight.hs
@@ -1,13 +1,18 @@
{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns -fno-warn-type-defaults #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
+import Control.DeepSeq
import qualified Crypto.Hash.SHA512 as SHA512
import qualified Data.ByteString as BS
import Weigh
+instance NFData SHA512.MAC where
+ rnf (SHA512.MAC b) = rnf b
+
-- note that 'weigh' doesn't work properly in a repl
main :: IO ()
main = mainWith $ do
@@ -21,10 +26,10 @@ hash =
!bs2 = BS.replicate 128 0
!bs3 = BS.replicate 12288 0
in wgroup "hash" $ do
- func' "hash (32B input)" SHA512.hash bs0
- func' "hash (64B input)" SHA512.hash bs1
- func' "hash (128B input)" SHA512.hash bs2
- func' "hash (12288B input)" SHA512.hash bs3
+ func "hash (32B input)" SHA512.hash bs0
+ func "hash (64B input)" SHA512.hash bs1
+ func "hash (128B input)" SHA512.hash bs2
+ func "hash (12288B input)" SHA512.hash bs3
hmac :: Weigh ()
hmac =
@@ -34,8 +39,8 @@ hmac =
!bs2 = BS.replicate 128 0
!bs3 = BS.replicate 12288 0
in wgroup "hmac" $ do
- func' "hmac (32B input)" (SHA512.hmac key) bs0
- func' "hmac (64B input)" (SHA512.hmac key) bs1
- func' "hmac (128B input)" (SHA512.hmac key) bs2
- func' "hmac (12288B input)" (SHA512.hmac key) bs3
+ func "hmac (32B input)" (SHA512.hmac key) bs0
+ func "hmac (64B input)" (SHA512.hmac key) bs1
+ func "hmac (128B input)" (SHA512.hmac key) bs2
+ func "hmac (12288B input)" (SHA512.hmac key) bs3
diff --git a/ppad-sha512.cabal b/ppad-sha512.cabal
@@ -94,6 +94,7 @@ benchmark sha512-weigh
build-depends:
base
, bytestring
+ , deepseq
, ppad-sha512
, weigh