Main.hs (1931B)
1 module Main where 2 3 import Criterion.Main 4 import Fixtures 5 import Lightning.Protocol.BOLT4 6 7 main :: IO () 8 main = defaultMain [ 9 env fixtures $ \fx -> bgroup "ppad-bolt4" [ 10 bgroup "construct" [ 11 bench "1 hop" $ 12 nf (construct (fx_session fx) (fx_route_1 fx)) (fx_ad fx) 13 , bench "5 hops" $ 14 nf (construct (fx_session fx) (fx_route_5 fx)) (fx_ad fx) 15 , bench "20 hops" $ 16 nf (construct (fx_session fx) (fx_route_20 fx)) (fx_ad fx) 17 ] 18 , bgroup "process" [ 19 bench "forward" $ 20 nf (process (fx_first_node fx) (fx_onion_5 fx) (fx_ad fx)) 21 Nothing 22 , bench "receive" $ 23 nf (process (fx_first_node fx) (fx_onion_1 fx) (fx_ad fx)) 24 Nothing 25 , bench "forward (blinded)" $ 26 nf (process (fx_blinded_node fx) (fx_blinded_onion fx) (fx_ad fx)) 27 (Just (fx_path_key fx)) 28 ] 29 , bgroup "returning errors" [ 30 bench "construct_error" $ 31 nf (construct_error (fx_secret fx)) (fx_failure fx) 32 , bench "wrap_error" $ 33 nf (wrap_error (fx_secret fx)) (fx_error fx) 34 , bench "unwrap_error (hop 4 of 5)" $ 35 nf (unwrap_error (fx_secrets_5 fx)) (fx_returned fx) 36 ] 37 , bgroup "route blinding" [ 38 bench "create_blinded_path (3 hops)" $ 39 nf (create_blinded_path (fx_path_seed fx)) (fx_path_nodes fx) 40 , bench "decrypt_recipient_data" $ 41 nf (decrypt_recipient_data (fx_blinded_node fx) (fx_path_key fx)) 42 (fx_encrypted fx) 43 ] 44 , bgroup "codecs" [ 45 bench "encode_onion_packet" $ 46 nf encode_onion_packet (fx_onion_5 fx) 47 , bench "decode_onion_packet" $ 48 nf decode_onion_packet (fx_onion_bytes fx) 49 , bench "encode_hop_payload" $ 50 nf encode_hop_payload (fx_payload fx) 51 , bench "decode_hop_payload" $ 52 nf decode_hop_payload (fx_payload_bytes fx) 53 ] 54 ] 55 ]