aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorJulien Tanguy <julien.tanguy@jhome.fr>2015-04-09 01:12:36 +0200
committerJulien Tanguy <julien.tanguy@jhome.fr>2015-04-09 01:12:36 +0200
commitf678145637ba6f42c36d07c19f8c764e5d537f72 (patch)
tree3e8578900501968de7404131a89e8e063dd0f12e /bench
downloadhmacaroons-f678145637ba6f42c36d07c19f8c764e5d537f72.tar.gz
hmacaroons-f678145637ba6f42c36d07c19f8c764e5d537f72.tar.zst
hmacaroons-f678145637ba6f42c36d07c19f8c764e5d537f72.zip
Initial commit
Diffstat (limited to 'bench')
-rw-r--r--bench/bench.hs35
1 files changed, 35 insertions, 0 deletions
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 @@
1{-#LANGUAGE OverloadedStrings #-}
2
3import Data.ByteString (ByteString)
4import Criterion.Main
5
6import Crypto.Macaroon
7import Crypto.Macaroon.Internal
8
9
10loc :: ByteString
11loc = "http://mybank/"
12
13ident :: ByteString
14ident = "we used our secret key"
15
16key :: ByteString
17key = "this is our super secret key; only we should know it"
18
19cav :: ByteString
20cav = "test = caveat"
21
22
23{-#INLINE benchCreate#-}
24benchCreate :: (Key, Key, Location) -> Macaroon
25benchCreate (secret, ident, loc) = create secret ident loc
26
27{-#INLINE benchMint #-}
28benchMint :: ((Key, Key, Location), ByteString) -> Macaroon
29benchMint (ms,c) = addFirstPartyCaveat c (benchCreate ms)
30
31main = defaultMain [
32 bgroup "Crypto.Macaroon" [ bench "create" $ nf benchCreate (key,ident,loc)
33 , bench "mint" $ nf benchMint ((key,ident,loc),cav)
34 ]
35 ]