OLD | NEW |
1 package parser | 1 package parser |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
| 5 "math" |
5 "net/url" | 6 "net/url" |
6 "strconv" | 7 "strconv" |
7 | 8 |
8 "skia.googlesource.com/buildbot.git/perf/go/config" | 9 "skia.googlesource.com/buildbot.git/perf/go/config" |
9 "skia.googlesource.com/buildbot.git/perf/go/types" | 10 "skia.googlesource.com/buildbot.git/perf/go/types" |
10 "skia.googlesource.com/buildbot.git/perf/go/vec" | 11 "skia.googlesource.com/buildbot.git/perf/go/vec" |
11 ) | 12 ) |
12 | 13 |
13 type FilterFunc struct{} | 14 type FilterFunc struct{} |
14 | 15 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 169 } |
169 } | 170 } |
170 return []*types.PerfTrace{ret}, nil | 171 return []*types.PerfTrace{ret}, nil |
171 } | 172 } |
172 | 173 |
173 func (AveFunc) Describe() string { | 174 func (AveFunc) Describe() string { |
174 return `ave() averages the values of all argument traces into a single t
race.` | 175 return `ave() averages the values of all argument traces into a single t
race.` |
175 } | 176 } |
176 | 177 |
177 var aveFunc = AveFunc{} | 178 var aveFunc = AveFunc{} |
| 179 |
| 180 type RatioFunc struct{} |
| 181 |
| 182 func (RatioFunc) Eval(ctx *Context, node *Node) ([]*types.PerfTrace, error) { |
| 183 if len(node.Args) != 2 { |
| 184 return nil, fmt.Errorf("ratio() takes two arguments") |
| 185 } |
| 186 |
| 187 tracesA, err := node.Args[0].Eval(ctx) |
| 188 if err != nil { |
| 189 return nil, fmt.Errorf("ratio() argument failed to evaluate: %s"
, err) |
| 190 } |
| 191 |
| 192 tracesB, err := node.Args[1].Eval(ctx) |
| 193 if err != nil { |
| 194 return nil, fmt.Errorf("ratio() argument failed to evaluate: %s"
, err) |
| 195 } |
| 196 |
| 197 ret := types.NewPerfTraceN(len(tracesA[0].Values)) |
| 198 for i, _ := range ret.Values { |
| 199 ret.Values[i] = tracesA[0].Values[i] / tracesB[0].Values[i] |
| 200 if math.IsInf(ret.Values[i], 0) { |
| 201 ret.Values[i] = config.MISSING_DATA_SENTINEL |
| 202 } |
| 203 } |
| 204 return []*types.PerfTrace{ret}, nil |
| 205 } |
| 206 |
| 207 func (RatioFunc) Describe() string { |
| 208 return `ratio(a, b) returns the point by point ratio of two traces. |
| 209 That is, it returns a trace with a[i]/b[i] for every point in a
and b.` |
| 210 } |
| 211 |
| 212 var ratioFunc = RatioFunc{} |
OLD | NEW |