Skip to content

Commit 63dc9ea

Browse files
p3rf Teamcopybara-github
authored andcommitted
"Fix" Sample.__eq__()
The previous implementation had 3 bugs: * it didn't compare units * it only compared metadata in one direction (which violates symmetry, i.e. x == y did not imply that y == x) * as a consequency of lack of symmetry, there existed values x,y such that x == y was true AND x != y was true. The "fix" is to just delete the method. This causes python to use the standard tuple equality method instead (which does the right thing). PiperOrigin-RevId: 716368687
1 parent 0cbbf12 commit 63dc9ea

File tree

5 files changed

+158
-26
lines changed

5 files changed

+158
-26
lines changed

perfkitbenchmarker/sample.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,6 @@ def __new__(
145145
**kwargs,
146146
)
147147

148-
def __eq__(self, other) -> bool:
149-
if not isinstance(other, Sample):
150-
# don't attempt to compare against unrelated types
151-
return NotImplemented
152-
if self.value != other.value:
153-
return False
154-
if self.metric != other.metric:
155-
return False
156-
if self.timestamp != other.timestamp:
157-
return False
158-
for key, value in other.metadata.items():
159-
if key not in self.metadata or self.metadata[key] != value:
160-
return False
161-
return True
162-
163148
def asdict(self) -> Dict[str, Any]: # pylint:disable=invalid-name
164149
"""Converts the Sample to a dictionary."""
165150
return self._asdict()

tests/linux_packages/aerospike_client_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ def testAggregateAsbenchSamples(self):
250250
'window': 1,
251251
'read_min': 61.0,
252252
'read_max': 68863.0,
253+
'read_p50': 685.0,
254+
'read_p90': 1201.0,
255+
'read_p99': 2008.0,
256+
'read_p99.9': 3315.0,
257+
'read_p99.99': 45471.0,
253258
},
254259
timestamp=0,
255260
),
@@ -265,6 +270,11 @@ def testAggregateAsbenchSamples(self):
265270
'window': 1,
266271
'write_min': 70.0,
267272
'write_max': 16735.0,
273+
'write_p50': 726.0,
274+
'write_p90': 1248.0,
275+
'write_p99': 2008.0,
276+
'write_p99.9': 3577.0,
277+
'write_p99.99': 13183.0,
268278
},
269279
timestamp=0,
270280
),
@@ -280,6 +290,11 @@ def testAggregateAsbenchSamples(self):
280290
'window': 1,
281291
'read_min': 61.0,
282292
'read_max': 68863.0,
293+
'read_p50': 712.0,
294+
'read_p90': 1230.0,
295+
'read_p99': 2026.0,
296+
'read_p99.9': 3095.0,
297+
'read_p99.99': 18607.0,
283298
},
284299
timestamp=0,
285300
),
@@ -295,6 +310,11 @@ def testAggregateAsbenchSamples(self):
295310
'window': 1,
296311
'write_min': 70.0,
297312
'write_max': 16735.0,
313+
'write_p50': 750.0,
314+
'write_p90': 1278.0,
315+
'write_p99': 2071.0,
316+
'write_p99.9': 3137.0,
317+
'write_p99.99': 8575.0,
298318
},
299319
timestamp=0,
300320
),
@@ -310,6 +330,11 @@ def testAggregateAsbenchSamples(self):
310330
'window': 1,
311331
'read_min': 61.0,
312332
'read_max': 68863.0,
333+
'read_p50': 718.0,
334+
'read_p90': 1236.0,
335+
'read_p99': 2031.0,
336+
'read_p99.9': 2981.0,
337+
'read_p99.99': 10303.0,
313338
},
314339
timestamp=0,
315340
),
@@ -325,6 +350,11 @@ def testAggregateAsbenchSamples(self):
325350
'window': 1,
326351
'write_min': 70.0,
327352
'write_max': 16735.0,
353+
'write_p50': 755.0,
354+
'write_p90': 1280.0,
355+
'write_p99': 2063.0,
356+
'write_p99.9': 3013.0,
357+
'write_p99.99': 8511.0,
328358
},
329359
timestamp=0,
330360
),

0 commit comments

Comments
 (0)