ppad-bolt4-0.1.0: bench/Main.hs
module Main where
import Criterion.Main
import Fixtures
import Lightning.Protocol.BOLT4
main :: IO ()
main = defaultMain [
env fixtures $ \fx -> bgroup "ppad-bolt4" [
bgroup "construct" [
bench "1 hop" $
nf (construct (fx_session fx) (fx_route_1 fx)) (fx_ad fx)
, bench "5 hops" $
nf (construct (fx_session fx) (fx_route_5 fx)) (fx_ad fx)
, bench "20 hops" $
nf (construct (fx_session fx) (fx_route_20 fx)) (fx_ad fx)
]
, bgroup "process" [
bench "forward" $
nf (process (fx_first_node fx) (fx_onion_5 fx) (fx_ad fx))
Nothing
, bench "receive" $
nf (process (fx_first_node fx) (fx_onion_1 fx) (fx_ad fx))
Nothing
, bench "forward (blinded)" $
nf (process (fx_blinded_node fx) (fx_blinded_onion fx) (fx_ad fx))
(Just (fx_path_key fx))
]
, bgroup "returning errors" [
bench "construct_error" $
nf (construct_error (fx_secret fx)) (fx_failure fx)
, bench "wrap_error" $
nf (wrap_error (fx_secret fx)) (fx_error fx)
, bench "unwrap_error (hop 4 of 5)" $
nf (unwrap_error (fx_secrets_5 fx)) (fx_returned fx)
]
, bgroup "route blinding" [
bench "create_blinded_path (3 hops)" $
nf (create_blinded_path (fx_path_seed fx)) (fx_path_nodes fx)
, bench "decrypt_recipient_data" $
nf (decrypt_recipient_data (fx_blinded_node fx) (fx_path_key fx))
(fx_encrypted fx)
]
, bgroup "codecs" [
bench "encode_onion_packet" $
nf encode_onion_packet (fx_onion_5 fx)
, bench "decode_onion_packet" $
nf decode_onion_packet (fx_onion_bytes fx)
, bench "encode_hop_payload" $
nf encode_hop_payload (fx_payload fx)
, bench "decode_hop_payload" $
nf decode_hop_payload (fx_payload_bytes fx)
]
]
]