Browse Source

remove -positive_percentages flag (#365)

Margaret Nolan 7 years ago
parent
commit
3b0df83c24
3 changed files with 19 additions and 34 deletions
  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 View File

135
 		"Ignore negative differences",
135
 		"Ignore negative differences",
136
 		"Do not show any locations with values <0.")},
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
 	// Graph handling options.
138
 	// Graph handling options.
147
 	"call_tree": &variable{boolKind, "f", "", helpText(
139
 	"call_tree": &variable{boolKind, "f", "", helpText(
148
 		"Create a context-sensitive call tree",
140
 		"Create a context-sensitive call tree",

+ 3
- 4
internal/driver/driver.go View File

250
 	}
250
 	}
251
 
251
 
252
 	ropt := &report.Options{
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
 		CompactLabels: vars["compact_labels"].boolValue(),
257
 		CompactLabels: vars["compact_labels"].boolValue(),
259
 		Ratio:         1 / vars["divide_by"].floatValue(),
258
 		Ratio:         1 / vars["divide_by"].floatValue(),

+ 16
- 22
internal/report/report.go View File

55
 type Options struct {
55
 type Options struct {
56
 	OutputFormat int
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
 	NodeCount    int
68
 	NodeCount    int
70
 	NodeFraction float64
69
 	NodeFraction float64
1192
 		}
1191
 		}
1193
 		return measurement.ScaledLabel(v, o.SampleUnit, o.OutputUnit)
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
 		o, format}
1195
 		o, format}
1197
 }
1196
 }
1198
 
1197
 
1213
 }
1212
 }
1214
 
1213
 
1215
 // computeTotal computes the sum of all sample values. This will be
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
 	var div, ret int64
1217
 	var div, ret int64
1222
 	for _, sample := range prof.Sample {
1218
 	for _, sample := range prof.Sample {
1223
 		var d, v int64
1219
 		var d, v int64
1225
 		if meanDiv != nil {
1221
 		if meanDiv != nil {
1226
 			d = meanDiv(sample.Value)
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
 	if div != 0 {
1230
 	if div != 0 {
1237
 		return ret / div
1231
 		return ret / div