Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: perf/go/parser/parser_test.go

Issue 610793003: Add ratio calculation to take the ratio of two calculations. (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: remove debug code Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « perf/go/parser/parser.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package parser 1 package parser
2 2
3 import ( 3 import (
4 "math" 4 "math"
5 "testing" 5 "testing"
6 6
7 "skia.googlesource.com/buildbot.git/perf/go/config" 7 "skia.googlesource.com/buildbot.git/perf/go/config"
8 "skia.googlesource.com/buildbot.git/perf/go/types" 8 "skia.googlesource.com/buildbot.git/perf/go/types"
9 ) 9 )
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 t.Errorf("ave() returned wrong length: Got %v Want %v", got, wan t) 124 t.Errorf("ave() returned wrong length: Got %v Want %v", got, wan t)
125 } 125 }
126 126
127 for i, want := range []float64{1.0, 0.5, -2.0, 1e100} { 127 for i, want := range []float64{1.0, 0.5, -2.0, 1e100} {
128 if got := traces[0].Values[i]; !near(got, want) { 128 if got := traces[0].Values[i]; !near(got, want) {
129 t.Errorf("Distance mismatch: Got %v Want %v", got, want) 129 t.Errorf("Distance mismatch: Got %v Want %v", got, want)
130 } 130 }
131 } 131 }
132 } 132 }
133 133
134 func TestRatio(t *testing.T) {
135 ctx := newTestContext()
136 ctx.Tile.Traces["t1"].(*types.PerfTrace).Values = []float64{10, 4, 100, 50, 9999, 0}
137 ctx.Tile.Traces["t2"].(*types.PerfTrace).Values = []float64{5, 2, 4, 5, 0, 1000}
138
139 traces, err := ctx.Eval(`ratio(
140 ave(fill(filter("config=gpu"))),
141 ave(fill(filter("config=8888"))))`)
142 if err != nil {
143 t.Fatalf("Failed to eval ratio() test: %s", err)
144 }
145 if got, want := len(traces), 1; got != want {
146 t.Errorf("ratio() returned wrong length: Got %v Want %v", got, w ant)
147 }
148 for i, want := range []float64{0.5, 0.5, 0.04, 0.1, 0, 1e+100} {
149 if got := traces[0].Values[i]; got != want {
150 t.Errorf("Ratio mismatch: Got %v Want %v", got, want)
151 }
152 }
153 }
154
134 func TestFill(t *testing.T) { 155 func TestFill(t *testing.T) {
135 ctx := newTestContext() 156 ctx := newTestContext()
136 ctx.Tile.Traces["t1"].(*types.PerfTrace).Values = []float64{1e100, 1e100 , 2, 3, 1e100, 5} 157 ctx.Tile.Traces["t1"].(*types.PerfTrace).Values = []float64{1e100, 1e100 , 2, 3, 1e100, 5}
137 delete(ctx.Tile.Traces, "t2") 158 delete(ctx.Tile.Traces, "t2")
138 traces, err := ctx.Eval(`fill(filter("config=8888"))`) 159 traces, err := ctx.Eval(`fill(filter("config=8888"))`)
139 if err != nil { 160 if err != nil {
140 t.Fatalf("Failed to eval fill() test: %s", err) 161 t.Fatalf("Failed to eval fill() test: %s", err)
141 } 162 }
142 if got, want := len(traces), 1; got != want { 163 if got, want := len(traces), 1; got != want {
143 t.Errorf("fill() returned wrong length: Got %v Want %v", got, wa nt) 164 t.Errorf("fill() returned wrong length: Got %v Want %v", got, wa nt)
144 } 165 }
145 166
146 for i, want := range []float64{2, 2, 2, 3, 3, 5} { 167 for i, want := range []float64{2, 2, 2, 3, 3, 5} {
147 if got := traces[0].Values[i]; !near(got, want) { 168 if got := traces[0].Values[i]; !near(got, want) {
148 t.Errorf("Distance mismatch: Got %v Want %v", got, want) 169 t.Errorf("Distance mismatch: Got %v Want %v", got, want)
149 } 170 }
150 } 171 }
151 } 172 }
OLDNEW
« no previous file with comments | « perf/go/parser/parser.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698