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) | |
| 187 if err != nil { | |
| 188 return nil, fmt.Errorf("ratio() argument failed to evaluate: %s" , err) | |
| 189 } | |
| 190 | |
| 191 traces, 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(traces[0].Values)) | |
| 197 for i, _ := range ret.Values { | |
| 198 fmt.Println(traces[0].Values[i]) | |
|
tfarina
2014/10/16 17:42:30
ret.Values[i] = traces[0].Values[i] / traces[1].Va
| |
| 199 } | |
| 200 | |
| 201 return nil, nil | |
|
tfarina
2014/10/16 17:42:30
return []*types.PerfTrace{ret}, nil
| |
| 202 } | |
| 203 | |
| 204 func (RatioFunc) Describe() string { | |
| 205 return `ratio(a, b) returns the point by point ratio of two traces. | |
| 206 That is, it returns a trace with a[i]/b[i] for every point in a and b.` | |
| 207 } | |
| 208 | |
| 209 var ratioFunc = RatioFunc{} | |
| OLD | NEW |