X-Git-Url: http://nitlanguage.org diff --git a/src/metrics/metrics_base.nit b/src/metrics/metrics_base.nit index 056aba4..c51e656 100644 --- a/src/metrics/metrics_base.nit +++ b/src/metrics/metrics_base.nit @@ -19,6 +19,7 @@ module metrics_base import model_utils +import modelbuilder import csv import counter import console @@ -86,7 +87,7 @@ redef class ToolContext self.option_context.add_option(opt_nocolors) end - redef fun process_options + redef fun process_options(args) do super var val = self.opt_dir.value @@ -170,6 +171,15 @@ interface Metric # Pretty print the metric results in console fun to_console(indent: Int, colors: Bool) do + if values.is_empty then + if colors then + print "{"\t" * indent}{name}: {desc} -- nothing".green + else + print "{"\t" * indent}{name}: {desc} -- nothing" + end + return + end + var max = self.max var min = self.min if colors then @@ -242,6 +252,15 @@ class IntMetric end return above end + + redef fun to_console(indent, colors) do + super + if colors then + print "{"\t" * indent} sum: {sum}".light_gray + else + print "{"\t" * indent} sum: {sum}" + end + end end # A Metric that collects float datas @@ -310,6 +329,16 @@ class FloatMetric end return above end + + redef fun to_console(indent, colors) do + super + if colors then + print "{"\t" * indent} sum: {sum}".light_gray + else + print "{"\t" * indent} sum: {sum}" + end + end + end # A MetricSet is a metric holder @@ -338,8 +367,10 @@ class MetricSet 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") @@ -361,7 +392,7 @@ class MetricSet line.add("n/a") end end - csv.lines.add(line) + csv.records.add(line) end return csv end