Skip to content

Commit

Permalink
remove -positive_percentages flag (google#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanmar511 authored and aalexand committed May 1, 2018
1 parent be265fa commit 3b0df83
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 34 deletions.
8 changes: 0 additions & 8 deletions internal/driver/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,6 @@ var pprofVariables = variables{
"Ignore negative differences",
"Do not show any locations with values <0.")},

// Comparisons.
"positive_percentages": &variable{boolKind, "f", "", helpText(
"Ignore negative samples when computing percentages",
"Do not count negative samples when computing the total value",
"of the profile, used to compute percentages. If set, and the -base",
"option is used, percentages reported will be computed against the",
"main profile, ignoring the base profile.")},

// Graph handling options.
"call_tree": &variable{boolKind, "f", "", helpText(
"Create a context-sensitive call tree",
Expand Down
7 changes: 3 additions & 4 deletions internal/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,9 @@ func reportOptions(p *profile.Profile, numLabelUnits map[string]string, vars var
}

ropt := &report.Options{
CumSort: vars["cum"].boolValue(),
CallTree: vars["call_tree"].boolValue(),
DropNegative: vars["drop_negative"].boolValue(),
PositivePercentages: vars["positive_percentages"].boolValue(),
CumSort: vars["cum"].boolValue(),
CallTree: vars["call_tree"].boolValue(),
DropNegative: vars["drop_negative"].boolValue(),

CompactLabels: vars["compact_labels"].boolValue(),
Ratio: 1 / vars["divide_by"].floatValue(),
Expand Down
38 changes: 16 additions & 22 deletions internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,15 @@ const (
type Options struct {
OutputFormat int

CumSort bool
CallTree bool
DropNegative bool
PositivePercentages bool
CompactLabels bool
Ratio float64
Title string
ProfileLabels []string
ActiveFilters []string
NumLabelUnits map[string]string
CumSort bool
CallTree bool
DropNegative bool
CompactLabels bool
Ratio float64
Title string
ProfileLabels []string
ActiveFilters []string
NumLabelUnits map[string]string

NodeCount int
NodeFraction float64
Expand Down Expand Up @@ -1192,7 +1191,7 @@ func New(prof *profile.Profile, o *Options) *Report {
}
return measurement.ScaledLabel(v, o.SampleUnit, o.OutputUnit)
}
return &Report{prof, computeTotal(prof, o.SampleValue, o.SampleMeanDivisor, !o.PositivePercentages),
return &Report{prof, computeTotal(prof, o.SampleValue, o.SampleMeanDivisor),
o, format}
}

Expand All @@ -1213,25 +1212,20 @@ func NewDefault(prof *profile.Profile, options Options) *Report {
}

// computeTotal computes the sum of all sample values. This will be
// used to compute percentages. If includeNegative is set, use use
// absolute values to provide a meaningful percentage for both
// negative and positive values. Otherwise only use positive values,
// which is useful when comparing profiles from different jobs.
func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64, includeNegative bool) int64 {
// used to compute percentages.
func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64) int64 {
var div, ret int64
for _, sample := range prof.Sample {
var d, v int64
v = value(sample.Value)
if meanDiv != nil {
d = meanDiv(sample.Value)
}
if v >= 0 {
ret += v
div += d
} else if includeNegative {
ret -= v
div += d
if v < 0 {
v = -v
}
ret += v
div += d
}
if div != 0 {
return ret / div
Expand Down

0 comments on commit 3b0df83

Please sign in to comment.