summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2016-02-25 15:17:11 +0100
committerRobin Burchell <robin.burchell@viroteck.net>2016-02-25 22:52:42 +0000
commit9be50ab01acf71f98d183a93667953303633c1cc (patch)
treebc3dc808114a34b9c70cfc6455507890db418df6 /src
parentd96ecf4751140252f7c4afbfcfdd78b5ad3486f0 (diff)
qtestcompare: Fix percentages and incorrect direction of verdict.
Calculated values were: (new - old) / new, which gives us a ratio, but to turn that into a percentage we need to multiply by 100. Also, if we have a negative percentage, there's a reduction (in time or instructions) which is a good thing, not a bad thing -- the calculation was the wrong way around. Change-Id: I56f165cc22c0f530c226ce7a569e79c7818c1a7f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/qtestcompare/main.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qtestcompare/main.go b/src/qtestcompare/main.go
index 1b585abd..a04eeaa2 100644
--- a/src/qtestcompare/main.go
+++ b/src/qtestcompare/main.go
@@ -81,9 +81,9 @@ func (s ByName) Less(i int, j int) bool {
func describeChange(pChange float64) string {
pStr := strconv.FormatFloat(pChange, 'f', 2, 64)
if pChange > 0 {
- return fmt.Sprintf("+%s%% FASTER! :)", pStr)
+ return fmt.Sprintf("+%s%%", pStr)
} else if pChange < 0 {
- return fmt.Sprintf("%s%%", pStr)
+ return fmt.Sprintf("%s%% FASTER! :)", pStr)
} else {
return "more or less the same"
}
@@ -164,14 +164,14 @@ func main() {
row = append(row, mr.Name)
if mr.OldInstructionReads != nil && mr.NewInstructionReads != nil {
- pChange := (*mr.NewInstructionReads - *mr.OldInstructionReads) / *mr.OldInstructionReads
+ pChange := (*mr.NewInstructionReads - *mr.OldInstructionReads) / *mr.OldInstructionReads * 100
totalPChange += pChange
row = append(row, strconv.FormatFloat(*mr.OldInstructionReads, 'f', 2, 64)+" instr")
row = append(row, strconv.FormatFloat(*mr.NewInstructionReads, 'f', 2, 64)+" instr")
row = append(row, describeChange(pChange))
} else if mr.OldDuration != nil && mr.NewDuration != nil {
- pChange := (*mr.NewDuration - *mr.OldDuration) / *mr.OldDuration
+ pChange := (*mr.NewDuration - *mr.OldDuration) / *mr.OldDuration * 100
totalPChange += pChange
row = append(row, strconv.FormatFloat(*mr.OldDuration, 'f', 2, 64)+" ms")
row = append(row, strconv.FormatFloat(*mr.NewDuration, 'f', 2, 64)+" ms")
@@ -209,9 +209,9 @@ func main() {
verdict := ""
totalPStr := strconv.FormatFloat(totalPChange, 'f', 2, 64)
if totalPChange > 0 {
- verdict = fmt.Sprintf("+%s%% :)", totalPStr)
+ verdict = fmt.Sprintf("+%s%% :(", totalPStr)
} else if totalPChange < 0 {
- verdict = fmt.Sprintf("%s%% :(", totalPStr)
+ verdict = fmt.Sprintf("%s%% :)", totalPStr)
} else {
verdict = "more or less the same"
}