From f678145637ba6f42c36d07c19f8c764e5d537f72 Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Thu, 9 Apr 2015 01:12:36 +0200 Subject: Initial commit --- bench/bench.hs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 bench/bench.hs (limited to 'bench') diff --git a/bench/bench.hs b/bench/bench.hs new file mode 100644 index 0000000..e66dadd --- /dev/null +++ b/bench/bench.hs @@ -0,0 +1,35 @@ +{-#LANGUAGE OverloadedStrings #-} + +import Data.ByteString (ByteString) +import Criterion.Main + +import Crypto.Macaroon +import Crypto.Macaroon.Internal + + +loc :: ByteString +loc = "http://mybank/" + +ident :: ByteString +ident = "we used our secret key" + +key :: ByteString +key = "this is our super secret key; only we should know it" + +cav :: ByteString +cav = "test = caveat" + + +{-#INLINE benchCreate#-} +benchCreate :: (Key, Key, Location) -> Macaroon +benchCreate (secret, ident, loc) = create secret ident loc + +{-#INLINE benchMint #-} +benchMint :: ((Key, Key, Location), ByteString) -> Macaroon +benchMint (ms,c) = addFirstPartyCaveat c (benchCreate ms) + +main = defaultMain [ + bgroup "Crypto.Macaroon" [ bench "create" $ nf benchCreate (key,ident,loc) + , bench "mint" $ nf benchMint ((key,ident,loc),cav) + ] + ] -- cgit v1.2.3