From: Jeffrey Czyz Date: Sun, 16 Jan 2022 16:16:19 +0000 (-0600) Subject: Benchmark zero-penalty scorer X-Git-Tag: v0.0.105~27^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=d924c5d6ed96479c8c262e61cbb1828b55ac9fe1;p=rust-lightning Benchmark zero-penalty scorer --- diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 8e3b5ae8f..cf2afbbba 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();