Chromium Code Reviews| 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 traces, err := node.Args[0].Eval(ctx) | |
|
jcgregorio
2014/09/29 15:09:22
Yes, you'll need to call Eval on both Args[0] and
tfarina
2014/10/01 02:30:16
Done.
| |
| 187 if err != nil { | |
| 188 return nil, fmt.Errorf("ratio() argument failed to evaluate: %s" , err) | |
| 189 } | |
| 190 | |
| 191 if len(traces) == 0 { | |
| 192 return traces, nil | |
| 193 } | |
| 194 | |
| 195 ret := types.NewPerfTraceN(len(traces[0].Values)) | |
|
tfarina
2014/09/30 13:35:14
Where the calc will go here?
You said in the e-ma
jcgregorio
2014/09/30 14:59:03
Yes, look at
for i, _ := range ret.Values
in A
tfarina
2014/10/01 02:30:16
I'm not sure yet how to proceed. Now I have traces
jcgregorio
2014/10/01 03:48:58
Yes, they will always have the same length.
On 20
| |
| 196 return []*types.PerfTrace{ret}, nil | |
| 197 } | |
| 198 | |
| 199 func (RatioFunc) Describe() string { | |
| 200 return `ratio() .` | |
|
tfarina
2014/09/30 13:35:14
could the description be something like:
"ratio()
jcgregorio
2014/09/30 14:59:03
`ratio(a, b) returns the point by point ratio of t
tfarina
2014/10/01 02:30:16
Done.
| |
| 201 } | |
| 202 | |
| 203 var ratioFunc = RatioFunc{} | |
| OLD | NEW |