@@ -1145,51 +1145,6 @@ impl MetricMap {
1145
1145
write ! ( & mut file, "{}" , json:: as_json( map) )
1146
1146
}
1147
1147
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
-
1193
1148
/// Insert a named `value` (+/- `noise`) metric into the map. The value
1194
1149
/// must be non-negative. The `noise` indicates the uncertainty of the
1195
1150
/// metric, which doubles as the "noise range" of acceptable
@@ -1218,14 +1173,8 @@ impl MetricMap {
1218
1173
/// file to contain the metrics in `self` if none of the
1219
1174
/// `MetricChange`s are `Regression`. Returns the diff as well
1220
1175
/// 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 ( ) ;
1229
1178
let ok = diff. iter ( ) . all ( |( _, v) | {
1230
1179
match * v {
1231
1180
_ => true
@@ -1644,14 +1593,6 @@ mod tests {
1644
1593
1645
1594
m1. insert_metric ( "in-both-want-upwards-and-improved" , 1000.0 , -10.0 ) ;
1646
1595
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 ) ;
1655
1596
}
1656
1597
1657
1598
#[ test]
@@ -1671,7 +1612,7 @@ mod tests {
1671
1612
m1. save ( & pth) . unwrap ( ) ;
1672
1613
1673
1614
// Ask for a ratchet that should fail to advance.
1674
- let ( diff1, ok1) = m2. ratchet ( & pth, None ) ;
1615
+ let ( diff1, ok1) = m2. ratchet ( & pth) ;
1675
1616
assert_eq ! ( ok1, false ) ;
1676
1617
assert_eq ! ( diff1. len( ) , 2 ) ;
1677
1618
@@ -1684,7 +1625,7 @@ mod tests {
1684
1625
1685
1626
// Ask for a ratchet with an explicit noise-percentage override,
1686
1627
// that should advance.
1687
- let ( diff2, ok2) = m2. ratchet ( & pth, Some ( 10.0 ) ) ;
1628
+ let ( diff2, ok2) = m2. ratchet ( & pth) ;
1688
1629
assert_eq ! ( ok2, true ) ;
1689
1630
assert_eq ! ( diff2. len( ) , 2 ) ;
1690
1631
0 commit comments