From: Jeffrey Czyz Date: Sun, 16 Jan 2022 16:16:19 +0000 (-0600) Subject: Benchmark zero-penalty scorer X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=ba8d084b357f0b18d68af3cda13e0585ad966ecd;p=rust-lightning Benchmark zero-penalty scorer --- diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 65a9e143e..2ddc4f5db 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -4978,6 +4978,15 @@ mod benches { fn log(&self, _record: &Record) {} } + struct ZeroPenaltyScorer; + impl Score for ZeroPenaltyScorer { + fn channel_penalty_msat( + &self, _short_channel_id: u64, _send_amt: u64, _capacity_msat: Option, _source: &NodeId, _target: &NodeId + ) -> u64 { 0 } + fn payment_path_failed(&mut self, _path: &[&RouteHop], _short_channel_id: u64) {} + fn payment_path_successful(&mut self, _path: &[&RouteHop]) {} + } + fn read_network_graph() -> NetworkGraph { let mut d = test_utils::get_route_file().unwrap(); NetworkGraph::read(&mut d).unwrap() @@ -5017,6 +5026,20 @@ mod benches { } } + #[bench] + fn generate_routes_with_zero_penalty_scorer(bench: &mut Bencher) { + let network_graph = read_network_graph(); + let scorer = ZeroPenaltyScorer; + generate_routes(bench, &network_graph, scorer, InvoiceFeatures::empty()); + } + + #[bench] + fn generate_mpp_routes_with_zero_penalty_scorer(bench: &mut Bencher) { + let network_graph = read_network_graph(); + let scorer = ZeroPenaltyScorer; + generate_routes(bench, &network_graph, scorer, InvoiceFeatures::known()); + } + #[bench] fn generate_routes_with_default_scorer(bench: &mut Bencher) { let network_graph = read_network_graph();