Main.hs (1192B)
1 module Main where 2 3 import Criterion.Main 4 import Data.Maybe (fromJust) 5 import qualified Lightning.Protocol.BOLT9 as B9 6 import Fixtures 7 8 basic_mpp :: B9.Feature 9 basic_mpp = fromJust (B9.featureByName "basic_mpp") 10 11 main :: IO () 12 main = defaultMain [ 13 bgroup "parse" [ 14 bench "typical (8 bytes)" $ nf B9.parse typicalBytes 15 , bench "empty" $ nf B9.parse emptyBytes 16 , bench "large (64 bytes)" $ nf B9.parse largeBytes 17 ] 18 19 , bgroup "render" [ 20 bench "typical" $ nf B9.render typicalFV 21 , bench "empty" $ nf B9.render emptyFV 22 ] 23 24 , bgroup "bit-ops" [ 25 bench "setBit" $ nf (B9.setBit 50) typicalFV 26 , bench "testBit" $ nf (B9.testBit 17) typicalFV 27 , bench "hasFeature" $ 28 nf (flip B9.hasFeature typicalFV) basic_mpp 29 ] 30 31 , bgroup "validate" [ 32 bench "validateLocal (valid)" $ 33 nf (B9.validateLocal B9.Init) validFV 34 , bench "validateRemote (unknown bits)" $ 35 nf (B9.validateRemote B9.Init) unknownBitsFV 36 ] 37 38 , bgroup "lookup" [ 39 bench "featureByBit" $ nf B9.featureByBit 16 40 , bench "featureByName" $ nf B9.featureByName "basic_mpp" 41 ] 42 ]