| 33 | |
| 34 | |
| 35 | def validate_report(report, iterations): |
| 36 | expected = {(case, iteration) for case in CASES for iteration in range(iterations)} |
| 37 | seen = set() |
| 38 | for sample in report['samples']: |
| 39 | key = (sample['case'], sample['iteration']) |
| 40 | if key not in expected or key in seen: |
| 41 | raise ValueError('unexpected or duplicate sample: ' + repr(key)) |
| 42 | seen.add(key) |
| 43 | if not isinstance(sample['total_ns'], int) or sample['total_ns'] <= 0: |
| 44 | raise ValueError('nonpositive or invalid sample duration') |
| 45 | if seen != expected: |
| 46 | raise ValueError('not all cases produced samples') |
| 47 | |
| 48 | |
| 49 | def summarize(report): |