You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a trivial benchmark of calculating routes on today's graph
Sadly rust upstream never really figured out the benchmark story,
and it looks like the API we use here may not be long for this
world. Luckily, we can switch to criterion with largely the same
API if that happens before upstream finishes ongoing work with the
custom test framework stuff.
Sadly, it requires fetching the current network graph, which I did
using Val's route-testing script written to test the MPP router.
Copy file name to clipboardExpand all lines: lightning/src/routing/router.rs
+44Lines changed: 44 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1279,3 +1279,47 @@ mod tests {
1279
1279
assert_eq!(route.paths[0][1].channel_features.le_flags(),&[0;0]);// We can't learn any flags from invoices, sadly
1280
1280
}
1281
1281
}
1282
+
1283
+
#[cfg(all(test, feature = "unstable"))]
1284
+
mod benches {
1285
+
usesuper::*;
1286
+
use util::logger::{Logger,Record};
1287
+
1288
+
use std::fs::File;
1289
+
use test::Bencher;
1290
+
1291
+
structDummyLogger{}
1292
+
implLoggerforDummyLogger{
1293
+
fnlog(&self,_record:&Record){}
1294
+
}
1295
+
1296
+
#[bench]
1297
+
fngenerate_routes(bench:&mutBencher){
1298
+
letmut d = File::open("net_graph-2021-02-12.bin").expect("Please fetch https://bitcoin.ninja/ldk-net_graph-879e309c128-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin");
1299
+
let graph = NetworkGraph::read(&mut d).unwrap();
1300
+
1301
+
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
1302
+
letmut path_endpoints = Vec::new();
1303
+
letmut seed:usize = 0xdeadbeef;
1304
+
'load_endpoints:for _ in0..100{
1305
+
loop{
1306
+
seed *= 0xdeadbeef;
1307
+
let src = graph.get_nodes().keys().skip(seed % graph.get_nodes().len()).next().unwrap();
1308
+
seed *= 0xdeadbeef;
1309
+
let dst = graph.get_nodes().keys().skip(seed % graph.get_nodes().len()).next().unwrap();
0 commit comments