+ var max = self.max
+ var min = self.min
+ if colors then
+ print "{"\t" * indent}{name}: {desc}".green
+ print "{"\t" * indent} avg: {avg}".light_gray
+ print "{"\t" * indent} max: {max} ({self[max]})".light_gray
+ print "{"\t" * indent} min: {min} ({self[min]})".light_gray
+ print "{"\t" * indent} std: {std_dev}".light_gray
+ else
+ print "{"\t" * indent}{name}: {desc}"
+ print "{"\t" * indent} avg: {avg}"
+ print "{"\t" * indent} max: {max} ({self[max]})"
+ print "{"\t" * indent} min: {min} ({self[min]})"
+ print "{"\t" * indent} std: {std_dev}"
+ end
+ end
+
+ # The sum of all the values.
+ fun sum: VAL is abstract
+
+ # The values standard derivation
+ fun std_dev: Float is abstract
+
+ # The element with the highest value
+ fun max: ELM is abstract
+
+ # The element with the lowest value
+ fun min: ELM is abstract
+
+ # The value threshold above what elements are considered as 'interesting'
+ fun threshold: Float do return avg + std_dev
+
+ # The set of element above the threshold
+ fun above_threshold: Set[ELM] is abstract
+
+ # Sort the metric keys by values
+ fun sort: Array[ELM] do
+ return values.keys_sorted_by_values(default_reverse_comparator)
+ end
+end
+
+# A Metric that collects integer data
+#
+# Used to count things
+class IntMetric
+ super Metric
+
+ redef type VAL: Int
+ redef type RES: Counter[ELM]
+
+ protected var values_cache = new Counter[ELM]
+ redef fun values do return values_cache
+
+ redef fun clear do values_cache.clear
+
+ redef fun sum do return values_cache.sum
+
+ redef fun max do
+ assert not values_cache.is_empty
+ return values_cache.max.as(not null)
+ end
+
+ redef fun min do
+ assert not values_cache.is_empty
+ return values_cache.min.as(not null)