Selaa lähdekoodia

remove -positive_percentages flag (#365)

Margaret Nolan 7 vuotta sitten
vanhempi
commit
3b0df83c24
3 muutettua tiedostoa jossa 19 lisäystä ja 34 poistoa
  1. 0
    8
      internal/driver/commands.go
  2. 3
    4
      internal/driver/driver.go
  3. 16
    22
      internal/report/report.go

+ 0
- 8
internal/driver/commands.go Näytä tiedosto

@@ -135,14 +135,6 @@ var pprofVariables = variables{
135 135
 		"Ignore negative differences",
136 136
 		"Do not show any locations with values <0.")},
137 137
 
138
-	// Comparisons.
139
-	"positive_percentages": &variable{boolKind, "f", "", helpText(
140
-		"Ignore negative samples when computing percentages",
141
-		"Do not count negative samples when computing the total value",
142
-		"of the profile, used to compute percentages. If set, and the -base",
143
-		"option is used, percentages reported will be computed against the",
144
-		"main profile, ignoring the base profile.")},
145
-
146 138
 	// Graph handling options.
147 139
 	"call_tree": &variable{boolKind, "f", "", helpText(
148 140
 		"Create a context-sensitive call tree",

+ 3
- 4
internal/driver/driver.go Näytä tiedosto

@@ -250,10 +250,9 @@ func reportOptions(p *profile.Profile, numLabelUnits map[string]string, vars var
250 250
 	}
251 251
 
252 252
 	ropt := &report.Options{
253
-		CumSort:             vars["cum"].boolValue(),
254
-		CallTree:            vars["call_tree"].boolValue(),
255
-		DropNegative:        vars["drop_negative"].boolValue(),
256
-		PositivePercentages: vars["positive_percentages"].boolValue(),
253
+		CumSort:      vars["cum"].boolValue(),
254
+		CallTree:     vars["call_tree"].boolValue(),
255
+		DropNegative: vars["drop_negative"].boolValue(),
257 256
 
258 257
 		CompactLabels: vars["compact_labels"].boolValue(),
259 258
 		Ratio:         1 / vars["divide_by"].floatValue(),

+ 16
- 22
internal/report/report.go Näytä tiedosto

@@ -55,16 +55,15 @@ const (
55 55
 type Options struct {
56 56
 	OutputFormat int
57 57
 
58
-	CumSort             bool
59
-	CallTree            bool
60
-	DropNegative        bool
61
-	PositivePercentages bool
62
-	CompactLabels       bool
63
-	Ratio               float64
64
-	Title               string
65
-	ProfileLabels       []string
66
-	ActiveFilters       []string
67
-	NumLabelUnits       map[string]string
58
+	CumSort       bool
59
+	CallTree      bool
60
+	DropNegative  bool
61
+	CompactLabels bool
62
+	Ratio         float64
63
+	Title         string
64
+	ProfileLabels []string
65
+	ActiveFilters []string
66
+	NumLabelUnits map[string]string
68 67
 
69 68
 	NodeCount    int
70 69
 	NodeFraction float64
@@ -1192,7 +1191,7 @@ func New(prof *profile.Profile, o *Options) *Report {
1192 1191
 		}
1193 1192
 		return measurement.ScaledLabel(v, o.SampleUnit, o.OutputUnit)
1194 1193
 	}
1195
-	return &Report{prof, computeTotal(prof, o.SampleValue, o.SampleMeanDivisor, !o.PositivePercentages),
1194
+	return &Report{prof, computeTotal(prof, o.SampleValue, o.SampleMeanDivisor),
1196 1195
 		o, format}
1197 1196
 }
1198 1197
 
@@ -1213,11 +1212,8 @@ func NewDefault(prof *profile.Profile, options Options) *Report {
1213 1212
 }
1214 1213
 
1215 1214
 // computeTotal computes the sum of all sample values. This will be
1216
-// used to compute percentages. If includeNegative is set, use use
1217
-// absolute values to provide a meaningful percentage for both
1218
-// negative and positive values. Otherwise only use positive values,
1219
-// which is useful when comparing profiles from different jobs.
1220
-func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64, includeNegative bool) int64 {
1215
+// used to compute percentages.
1216
+func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64) int64 {
1221 1217
 	var div, ret int64
1222 1218
 	for _, sample := range prof.Sample {
1223 1219
 		var d, v int64
@@ -1225,13 +1221,11 @@ func computeTotal(prof *profile.Profile, value, meanDiv func(v []int64) int64, i
1225 1221
 		if meanDiv != nil {
1226 1222
 			d = meanDiv(sample.Value)
1227 1223
 		}
1228
-		if v >= 0 {
1229
-			ret += v
1230
-			div += d
1231
-		} else if includeNegative {
1232
-			ret -= v
1233
-			div += d
1224
+		if v < 0 {
1225
+			v = -v
1234 1226
 		}
1227
+		ret += v
1228
+		div += d
1235 1229
 	}
1236 1230
 	if div != 0 {
1237 1231
 		return ret / div