OLD | NEW |
---|---|
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 Loading... | |
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} | |
137 ctx.Tile.Traces["t2"].(*types.PerfTrace).Values = []float64{5, 2, 4, 5} | |
jcgregorio
2014/10/18 00:19:13
Add a divide by zero case to the tests.
tfarina
2014/10/18 03:15:46
Done.
| |
138 | |
139 _, 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 } | |
jcgregorio
2014/10/18 00:19:13
Add tests for the values coming from the result of
tfarina
2014/10/18 03:15:46
Done.
| |
145 } | |
146 | |
134 func TestFill(t *testing.T) { | 147 func TestFill(t *testing.T) { |
135 ctx := newTestContext() | 148 ctx := newTestContext() |
136 ctx.Tile.Traces["t1"].(*types.PerfTrace).Values = []float64{1e100, 1e100 , 2, 3, 1e100, 5} | 149 ctx.Tile.Traces["t1"].(*types.PerfTrace).Values = []float64{1e100, 1e100 , 2, 3, 1e100, 5} |
137 delete(ctx.Tile.Traces, "t2") | 150 delete(ctx.Tile.Traces, "t2") |
138 traces, err := ctx.Eval(`fill(filter("config=8888"))`) | 151 traces, err := ctx.Eval(`fill(filter("config=8888"))`) |
139 if err != nil { | 152 if err != nil { |
140 t.Fatalf("Failed to eval fill() test: %s", err) | 153 t.Fatalf("Failed to eval fill() test: %s", err) |
141 } | 154 } |
142 if got, want := len(traces), 1; got != want { | 155 if got, want := len(traces), 1; got != want { |
143 t.Errorf("fill() returned wrong length: Got %v Want %v", got, wa nt) | 156 t.Errorf("fill() returned wrong length: Got %v Want %v", got, wa nt) |
144 } | 157 } |
145 | 158 |
146 for i, want := range []float64{2, 2, 2, 3, 3, 5} { | 159 for i, want := range []float64{2, 2, 2, 3, 3, 5} { |
147 if got := traces[0].Values[i]; !near(got, want) { | 160 if got := traces[0].Values[i]; !near(got, want) { |
148 t.Errorf("Distance mismatch: Got %v Want %v", got, want) | 161 t.Errorf("Distance mismatch: Got %v Want %v", got, want) |
149 } | 162 } |
150 } | 163 } |
151 } | 164 } |
OLD | NEW |