Optimize reference graph container value type for topological_sort.

Optimize initial container capacity estimates.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2026-02-14 10:23:47 +00:00
parent b7ea9714e8
commit 1bd4ab0601
15 changed files with 192 additions and 155 deletions

View File

@@ -41,16 +41,20 @@ criterion_main!(benches);
static SERVER_TIMESTAMP: AtomicU64 = AtomicU64::new(0);
#[expect(
clippy::iter_on_single_items,
clippy::iter_on_empty_collections
)]
fn lexico_topo_sort(c: &mut Criterion) {
c.bench_function("lexico_topo_sort", |c| {
use maplit::{hashmap, hashset};
use maplit::hashmap;
let graph = hashmap! {
event_id("l") => hashset![event_id("o")],
event_id("m") => hashset![event_id("n"), event_id("o")],
event_id("n") => hashset![event_id("o")],
event_id("o") => hashset![], // "o" has zero outgoing edges but 4 incoming edges
event_id("p") => hashset![event_id("o")],
event_id("l") => [event_id("o")].into_iter().collect(),
event_id("m") => [event_id("n"), event_id("o")].into_iter().collect(),
event_id("n") => [event_id("o")].into_iter().collect(),
event_id("o") => [].into_iter().collect(), // "o" has zero outgoing edges but 4 incoming edges
event_id("p") => [event_id("o")].into_iter().collect(),
};
c.to_async(FuturesExecutor).iter(async || {