aboutsummaryrefslogtreecommitdiff
path: root/src/crates/candelabra
diff options
context:
space:
mode:
authorAria Shrimpton <me@aria.rip>2024-03-08 17:49:30 +0000
committerAria Shrimpton <me@aria.rip>2024-03-08 17:49:30 +0000
commit7aeb5a30c469c01ee00a3f64ff09d2bff43e81be (patch)
tree1a5cd63a2998e94ada473e3837c851cea6945d3f /src/crates/candelabra
parent1103ebb77e208fb5aee7d105cafb9fa9e3e6dfad (diff)
adaptive suggestion fixes
Diffstat (limited to 'src/crates/candelabra')
-rw-r--r--src/crates/candelabra/src/profiler/info.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/crates/candelabra/src/profiler/info.rs b/src/crates/candelabra/src/profiler/info.rs
index cde1e2c..78ce299 100644
--- a/src/crates/candelabra/src/profiler/info.rs
+++ b/src/crates/candelabra/src/profiler/info.rs
@@ -108,12 +108,10 @@ impl UsageProfile {
// calculate cost of switching
let before = &top_by_partition[0].0;
let after = &top_by_partition[split_idx].0;
- let before_model = candidates.get(before).unwrap();
- let after_model = candidates.get(after).unwrap();
let copy_n = self.0[split_idx].avg_n;
- let switching_cost = after_model.by_op.get("insert")?.estimatef(copy_n)
- + before_model.by_op.get("clear")?.estimatef(copy_n);
+ let after_model = candidates.get(after).unwrap();
+ let switching_cost = copy_n * after_model.by_op.get("insert")?.estimatef(copy_n / 2.0);
// see if it's "worth it"
let before_costs = &costs_by_partitions
@@ -141,7 +139,7 @@ impl UsageProfile {
threshold: copy_n as usize,
after: after.to_string(),
},
- top_by_partition.iter().map(|(_, v)| v).sum(),
+ top_by_partition.iter().map(|(_, v)| v).sum::<f64>() + switching_cost,
))
}
}