diff options
author | Aria <me@aria.rip> | 2023-10-31 15:24:15 +0000 |
---|---|---|
committer | Aria <me@aria.rip> | 2023-10-31 15:24:15 +0000 |
commit | 56eabd5ff57936e923c2f65f0603bfc18f6b6830 (patch) | |
tree | 0bae7fb165212a9c72c9dff5f1e9577431d365ba | |
parent | 5f6fdf53296c138e5e97e97fa640137866aab56a (diff) |
feat(benchmarker): merging results
-rw-r--r-- | primrose/crates/candelabra-benchmarker/src/lib.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/primrose/crates/candelabra-benchmarker/src/lib.rs b/primrose/crates/candelabra-benchmarker/src/lib.rs index 104dace..c69d699 100644 --- a/primrose/crates/candelabra-benchmarker/src/lib.rs +++ b/primrose/crates/candelabra-benchmarker/src/lib.rs @@ -38,3 +38,30 @@ pub struct RunResults { /// The average (mean) time taken pub avg: Duration, } + +impl Results { + pub fn merge(&mut self, b: Self) -> &mut Self { + for (n, res_b) in b.by_n { + self.by_n + .entry(n) + .and_modify(|res_a| { + res_a.merge(res_b.clone()); + }) + .or_insert(res_b); + } + + self + } +} + +impl SingleNResults { + /// Merge results from `b` into these results. + /// If `b` contains benchmarks for operations we have a result for, results from `b` are preferred. + pub fn merge(&mut self, b: Self) -> &mut Self { + for (name, res_b) in b.by_op { + self.by_op.insert(name, res_b); + } + + self + } +} |