Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanmar511 committed May 11, 2018
1 parent ee3be39 commit 562c51d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
8 changes: 6 additions & 2 deletions internal/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ type testFlags struct {
floats map[string]float64
strings map[string]string
args []string
stringLists map[string][]*string
stringLists map[string][]string
}

func (testFlags) ExtraUsage() string { return "" }
Expand Down Expand Up @@ -355,7 +355,11 @@ func (f testFlags) StringVar(p *string, s, d, c string) {

func (f testFlags) StringList(s, d, c string) *[]*string {
if t, ok := f.stringLists[s]; ok {
return &t
tp := make([]*string, len(t))
for i, v := range t {
tp[i] = &v
}
return &tp
}
return &[]*string{}
}
Expand Down
22 changes: 6 additions & 16 deletions internal/driver/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,20 +437,10 @@ func TestFetchWithBase(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.desc, func(t *testing.T) {
pprofVariables = baseVars.makeCopy()
base := make([]*string, len(tc.bases))
for i, s := range tc.bases {
base[i] = &s
}

diffBase := make([]*string, len(tc.diffBases))
for i, s := range tc.diffBases {
diffBase[i] = &s
}

f := testFlags{
stringLists: map[string][]*string{
"base": base,
"diff_base": diffBase,
stringLists: map[string][]string{
"base": tc.bases,
"diff_base": tc.diffBases,
},
bools: map[string]bool{
"normalize": tc.normalize,
Expand All @@ -468,8 +458,8 @@ func TestFetchWithBase(t *testing.T) {
if err == nil {
t.Fatalf("got nil, want error %q", tc.wantErrorMsg)
}
gotErrMsg := err.Error()
if gotErrMsg != tc.wantErrorMsg {

if gotErrMsg := err.Error(); gotErrMsg != tc.wantErrorMsg {
t.Fatalf("got error %q, want error %q", gotErrMsg, tc.wantErrorMsg)
}
return
Expand All @@ -485,7 +475,7 @@ func TestFetchWithBase(t *testing.T) {
t.Fatal(err)
}

if want, got := len(tc.wantSamples), len(p.Sample); want != got {
if got, want := len(p.Sample), len(tc.wantSamples); got != want {
t.Fatalf("got %d samples want %d", got, want)
}

Expand Down
6 changes: 3 additions & 3 deletions internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (rpt *Report) newGraph(nodes graph.NodeSet) *graph.Graph {
s.NumUnit = numUnits
}

// Remove tag marking samples from the base profiles, so it does not appear
// Remove label marking samples from the base profiles, so it does not appear
// as a nodelet in the graph view.
prof.RemoveLabel("pprof::base")

Expand Down Expand Up @@ -1217,8 +1217,8 @@ func NewDefault(prof *profile.Profile, options Options) *Report {
}

// computeTotal computes the sum of the absolute value of all sample values.
// If any samples have the tag "pprof::base" with value "true", then the total
// will only include samples with that tag.
// If any samples have the label "pprof::base" with value "true", then the total
// will only include samples with that label.
func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64) int64 {
var div, total, diffDiv, diffTotal int64
for _, sample := range prof.Sample {
Expand Down

0 comments on commit 562c51d

Please sign in to comment.