Chromium Code Reviews| 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{1.0, -1.0, 1 e100, 1e100} | |
|
tfarina
2014/10/16 17:42:30
I think I can have more reasonable numbers in thes
| |
| 137 ctx.Tile.Traces["t2"].(*types.PerfTrace).Values = []float64{1e100, 2.0, -2.0, 1e100} | |
| 138 } | |
|
tfarina
2014/10/16 17:42:30
Then have:
traces, err := ctx.Eval(`ratio( ave(f
| |
| 139 | |
| 134 func TestFill(t *testing.T) { | 140 func TestFill(t *testing.T) { |
| 135 ctx := newTestContext() | 141 ctx := newTestContext() |
| 136 ctx.Tile.Traces["t1"].(*types.PerfTrace).Values = []float64{1e100, 1e100 , 2, 3, 1e100, 5} | 142 ctx.Tile.Traces["t1"].(*types.PerfTrace).Values = []float64{1e100, 1e100 , 2, 3, 1e100, 5} |
| 137 delete(ctx.Tile.Traces, "t2") | 143 delete(ctx.Tile.Traces, "t2") |
| 138 traces, err := ctx.Eval(`fill(filter("config=8888"))`) | 144 traces, err := ctx.Eval(`fill(filter("config=8888"))`) |
| 139 if err != nil { | 145 if err != nil { |
| 140 t.Fatalf("Failed to eval fill() test: %s", err) | 146 t.Fatalf("Failed to eval fill() test: %s", err) |
| 141 } | 147 } |
| 142 if got, want := len(traces), 1; got != want { | 148 if got, want := len(traces), 1; got != want { |
| 143 t.Errorf("fill() returned wrong length: Got %v Want %v", got, wa nt) | 149 t.Errorf("fill() returned wrong length: Got %v Want %v", got, wa nt) |
| 144 } | 150 } |
| 145 | 151 |
| 146 for i, want := range []float64{2, 2, 2, 3, 3, 5} { | 152 for i, want := range []float64{2, 2, 2, 3, 3, 5} { |
| 147 if got := traces[0].Values[i]; !near(got, want) { | 153 if got := traces[0].Values[i]; !near(got, want) { |
| 148 t.Errorf("Distance mismatch: Got %v Want %v", got, want) | 154 t.Errorf("Distance mismatch: Got %v Want %v", got, want) |
| 149 } | 155 } |
| 150 } | 156 } |
| 151 } | 157 } |
| OLD | NEW |