module metrics_base
import model_utils
+import modelbuilder
import csv
import counter
import console
end
end
+ # The sum of all the values.
+ fun sum: VAL is abstract
+
# The values standard derivation
fun std_dev: Float is abstract
# 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
redef fun clear do values_cache.clear
- fun sum: Int do return values_cache.sum
+ redef fun sum do return values_cache.sum
redef fun max do
assert not values_cache.is_empty
redef fun clear do values_cache.clear
- fun sum: Float do
+
+ redef fun sum do
var sum = 0.0
for v in values.values do sum += v
return sum
print "{"\t" * indent} sum: {sum}"
end
end
-
end
# A MetricSet is a metric holder
end
# Export the metric set in CSV format
- fun to_csv: CSVDocument do
- var csv = new CSVDocument
+ fun to_csv: CsvDocument do
+ var csv = new CsvDocument
+
+ csv.format = new CsvFormat('"', ';', "\n")
# set csv headers
csv.header.add("entry")
line.add("n/a")
end
end
- csv.lines.add(line)
+ csv.records.add(line)
end
return csv
end