Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: perf/go/parser/funcs.go

Issue 610793003: Add ratio calculation to take the ratio of two calculations. (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: review Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | perf/go/parser/parser.go » ('j') | perf/go/parser/parser_test.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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{}
OLDNEW
« no previous file with comments | « no previous file | perf/go/parser/parser.go » ('j') | perf/go/parser/parser_test.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698