Last active
March 21, 2022 19:32
-
-
Save tnull/86ef4f5e87b40d0ce829196e2010dfd3 to your computer and use it in GitHub Desktop.
Compare different `sort` variants for LDK's `get_route`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut paths_cached = payment_paths.clone(); | |
let instant_cached = Instant::now(); | |
paths_cached.sort_by_cached_key(|path| path.get_total_fee_paid_msat()); | |
println!("Cached sort took: {}", instant_cached.elapsed().as_nanos()); | |
let mut paths_unstable = payment_paths.clone(); | |
let instant_unstable = Instant::now(); | |
paths_unstable.sort_unstable_by_key(|path| path.get_total_fee_paid_msat()); | |
println!("Unstable sort took: {}", instant_unstable.elapsed().as_nanos()); | |
let mut paths_stable = payment_paths.clone(); | |
let instant_stable = Instant::now(); | |
paths_stable.sort_by_key(|path| path.get_total_fee_paid_msat()); | |
println!("Stable sort took: {}", instant_stable.elapsed().as_nanos()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment