mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #19328 from palimondo/test-twice-commit-once
[benchmark] Report Quantiles from Benchmark_O and a TON of Gardening (take 2)
This commit is contained in:
@@ -34,6 +34,7 @@ import re
|
||||
import sys
|
||||
from bisect import bisect, bisect_left, bisect_right
|
||||
from collections import namedtuple
|
||||
from decimal import Decimal, ROUND_HALF_EVEN
|
||||
from math import sqrt
|
||||
|
||||
|
||||
@@ -141,20 +142,32 @@ class PerformanceTestSamples(object):
|
||||
"""Maximum sampled value."""
|
||||
return self.samples[-1].runtime
|
||||
|
||||
def quantile(self, q):
|
||||
"""Return runtime of a sample nearest to the quantile.
|
||||
|
||||
Explicitly uses round-half-to-even rounding algorithm to match the
|
||||
behavior of numpy's quantile(interpolation='nearest') and quantile
|
||||
estimate type R-3, SAS-2. See:
|
||||
https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample
|
||||
"""
|
||||
index = int(Decimal((self.count - 1) * Decimal(q))
|
||||
.quantize(0, ROUND_HALF_EVEN))
|
||||
return self.samples[index].runtime
|
||||
|
||||
@property
|
||||
def median(self):
|
||||
"""Median sampled value."""
|
||||
return self.samples[self.count / 2].runtime
|
||||
return self.quantile(0.5)
|
||||
|
||||
@property
|
||||
def q1(self):
|
||||
"""First Quartile (25th Percentile)."""
|
||||
return self.samples[self.count / 4].runtime
|
||||
return self.quantile(0.25)
|
||||
|
||||
@property
|
||||
def q3(self):
|
||||
"""Third Quartile (75th Percentile)."""
|
||||
return self.samples[(self.count / 2) + (self.count / 4)].runtime
|
||||
return self.quantile(0.75)
|
||||
|
||||
@property
|
||||
def iqr(self):
|
||||
|
||||
Reference in New Issue
Block a user