| 92 | |
| 93 | |
| 94 | class BenchmarkResult: |
| 95 | def __init__(self, units, count, result, sigma): |
| 96 | self.units_ = units |
| 97 | self.count_ = float(count) |
| 98 | self.result_ = float(result) |
| 99 | self.sigma_ = float(sigma) |
| 100 | |
| 101 | def Compare(self, other): |
| 102 | if self.units_ != other.units_: |
| 103 | print ("Incompatible units: %s and %s" % (self.units_, other.units_)) |
| 104 | sys.exit(1) |
| 105 | |
| 106 | significant = False |
| 107 | notable = 0 |
| 108 | percentage_string = "" |
| 109 | # compute notability and significance. |
| 110 | if self.units_ == "score": |
| 111 | compare_num = 100*self.result_/other.result_ - 100 |
| 112 | else: |
| 113 | compare_num = 100*other.result_/self.result_ - 100 |
| 114 | if abs(compare_num) > 0.1: |
| 115 | percentage_string = "%3.1f" % (compare_num) |
| 116 | z = Statistics.ComputeZ(other.result_, other.sigma_, |
| 117 | self.result_, self.count_) |
| 118 | p = Statistics.ComputeProbability(z) |
| 119 | if p < PROBABILITY_CONSIDERED_SIGNIFICANT: |
| 120 | significant = True |
| 121 | if compare_num >= PERCENT_CONSIDERED_SIGNIFICANT: |
| 122 | notable = 1 |
| 123 | elif compare_num <= -PERCENT_CONSIDERED_SIGNIFICANT: |
| 124 | notable = -1 |
| 125 | return ResultsDiff(significant, notable, percentage_string) |
| 126 | |
| 127 | def result(self): |
| 128 | return self.result_ |
| 129 | |
| 130 | def sigma(self): |
| 131 | return self.sigma_ |
| 132 | |
| 133 | |
| 134 | class Benchmark: |