Skip to content

Commit 72ae518

Browse files
committed
Remove compare_to_old().
1 parent f5e093f commit 72ae518

File tree

1 file changed

+4
-63
lines changed

1 file changed

+4
-63
lines changed

src/libtest/lib.rs

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,51 +1145,6 @@ impl MetricMap {
11451145
write!(&mut file, "{}", json::as_json(map))
11461146
}
11471147

1148-
/// Compare against another MetricMap. Optionally compare all
1149-
/// measurements in the maps using the provided `noise_pct` as a
1150-
/// percentage of each value to consider noise. If `None`, each
1151-
/// measurement's noise threshold is independently chosen as the
1152-
/// maximum of that measurement's recorded noise quantity in either
1153-
/// map.
1154-
pub fn compare_to_old(&self, old: &MetricMap,
1155-
noise_pct: Option<f64>) -> MetricDiff {
1156-
let mut diff : MetricDiff = BTreeMap::new();
1157-
let MetricMap(ref selfmap) = *self;
1158-
let MetricMap(ref old) = *old;
1159-
for (k, vold) in old.iter() {
1160-
match selfmap.get(k) {
1161-
None => (),
1162-
Some(v) => {
1163-
let delta = v.value - vold.value;
1164-
let noise = match noise_pct {
1165-
None => vold.noise.abs().max(v.noise.abs()),
1166-
Some(pct) => vold.value * pct / 100.0
1167-
};
1168-
if delta.abs() <= noise {
1169-
} else {
1170-
if vold.noise < 0.0 {
1171-
// When 'noise' is negative, it means we want
1172-
// to see deltas that go up over time, and can
1173-
// only tolerate slight negative movement.
1174-
if delta < 0.0 {
1175-
} else {
1176-
}
1177-
} else {
1178-
// When 'noise' is positive, it means we want
1179-
// to see deltas that go down over time, and
1180-
// can only tolerate slight positive movements.
1181-
if delta < 0.0 {
1182-
} else {
1183-
}
1184-
}
1185-
}
1186-
}
1187-
};
1188-
diff.insert((*k).clone(), MetricChange);
1189-
}
1190-
diff
1191-
}
1192-
11931148
/// Insert a named `value` (+/- `noise`) metric into the map. The value
11941149
/// must be non-negative. The `noise` indicates the uncertainty of the
11951150
/// metric, which doubles as the "noise range" of acceptable
@@ -1218,14 +1173,8 @@ impl MetricMap {
12181173
/// file to contain the metrics in `self` if none of the
12191174
/// `MetricChange`s are `Regression`. Returns the diff as well
12201175
/// as a boolean indicating whether the ratchet succeeded.
1221-
pub fn ratchet(&self, p: &Path, pct: Option<f64>) -> (MetricDiff, bool) {
1222-
let old = if p.exists() {
1223-
MetricMap::load(p)
1224-
} else {
1225-
MetricMap::new()
1226-
};
1227-
1228-
let diff : MetricDiff = self.compare_to_old(&old, pct);
1176+
pub fn ratchet(&self, p: &Path) -> (MetricDiff, bool) {
1177+
let diff : MetricDiff = BTreeMap::new();
12291178
let ok = diff.iter().all(|(_, v)| {
12301179
match *v {
12311180
_ => true
@@ -1644,14 +1593,6 @@ mod tests {
16441593

16451594
m1.insert_metric("in-both-want-upwards-and-improved", 1000.0, -10.0);
16461595
m2.insert_metric("in-both-want-upwards-and-improved", 2000.0, -10.0);
1647-
1648-
let diff1 = m2.compare_to_old(&m1, None);
1649-
1650-
assert_eq!(diff1.len(), 7);
1651-
1652-
let diff2 = m2.compare_to_old(&m1, Some(200.0));
1653-
1654-
assert_eq!(diff2.len(), 7);
16551596
}
16561597

16571598
#[test]
@@ -1671,7 +1612,7 @@ mod tests {
16711612
m1.save(&pth).unwrap();
16721613

16731614
// Ask for a ratchet that should fail to advance.
1674-
let (diff1, ok1) = m2.ratchet(&pth, None);
1615+
let (diff1, ok1) = m2.ratchet(&pth);
16751616
assert_eq!(ok1, false);
16761617
assert_eq!(diff1.len(), 2);
16771618

@@ -1684,7 +1625,7 @@ mod tests {
16841625

16851626
// Ask for a ratchet with an explicit noise-percentage override,
16861627
// that should advance.
1687-
let (diff2, ok2) = m2.ratchet(&pth, Some(10.0));
1628+
let (diff2, ok2) = m2.ratchet(&pth);
16881629
assert_eq!(ok2, true);
16891630
assert_eq!(diff2.len(), 2);
16901631

0 commit comments

Comments
 (0)