From 3b0df83c245cf8e0ecc91f80c05ae0b34d3e2cf8 Mon Sep 17 00:00:00 2001 From: Margaret Nolan Date: Mon, 30 Apr 2018 19:07:02 -0700 Subject: [PATCH] remove -positive_percentages flag (#365) --- internal/driver/commands.go | 8 -------- internal/driver/driver.go | 7 +++---- internal/report/report.go | 38 ++++++++++++++++--------------------- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/internal/driver/commands.go b/internal/driver/commands.go index 16b0b0a3..80658314 100644 --- a/internal/driver/commands.go +++ b/internal/driver/commands.go @@ -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", diff --git a/internal/driver/driver.go b/internal/driver/driver.go index 3b7439fc..0a14c67a 100644 --- a/internal/driver/driver.go +++ b/internal/driver/driver.go @@ -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(), diff --git a/internal/report/report.go b/internal/report/report.go index e127f7fc..fa0ee3b9 100644 --- a/internal/report/report.go +++ b/internal/report/report.go @@ -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 @@ -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} } @@ -1213,11 +1212,8 @@ 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 @@ -1225,13 +1221,11 @@ func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64, i 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