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