]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Benchmark zero-penalty scorer
authorJeffrey Czyz <jkczyz@gmail.com>
Sun, 16 Jan 2022 16:16:19 +0000 (10:16 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 20 Jan 2022 20:05:19 +0000 (14:05 -0600)
lightning/src/routing/router.rs

index 65a9e143eece72cd563445df73a2cc87549aea70..2ddc4f5db461f445d3d6d2233671de47d7919a6c 100644 (file)
@@ -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<u64>, _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();