mmodules.add_all(mgroup.mmodules)
mclasses.add_all(mod_mclasses)
cmetrics.collect(new HashSet[MClass].from(mod_mclasses))
- for metric in cmetrics.metrics do
- if metric isa IntMetric then
- print toolcontext.format_h4("\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
hmetrics.collect(new HashSet[MModule].from(mgroup.mmodules))
- for metric in hmetrics.metrics do
- if metric isa FloatMetric then
- print toolcontext.format_h4("\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ hmetrics.to_console(1, not toolcontext.opt_nocolors.value)
end
end
if not mclasses.is_empty then
print toolcontext.format_h2("\n ## global metrics")
cmetrics.clear
cmetrics.collect(mclasses)
- for metric in cmetrics.metrics do
- if metric isa IntMetric then
- print toolcontext.format_h4("\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
hmetrics.clear
hmetrics.collect(mmodules)
- for metric in hmetrics.metrics do
- if metric isa FloatMetric then
- print toolcontext.format_h4("\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ hmetrics.to_console(1, not toolcontext.opt_nocolors.value)
end
end
end
# Scalar metrics
print toolcontext.format_h3(" `- group {mgroup.full_name}")
-
var mod_mclasses = new HashSet[MClass]
for mmodule in mgroup.mmodules do mod_mclasses.add_all(mmodule.intro_mclasses)
if mod_mclasses.is_empty then continue
mclasses.add_all(mod_mclasses)
metrics.collect(new HashSet[MClass].from(mod_mclasses))
- for metric in metrics.metrics do
- if metric isa IntMetric then
- print toolcontext.format_h4("\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ metrics.to_console(1, not toolcontext.opt_nocolors.value)
end
end
if not mclasses.is_empty then
# Global metrics
print toolcontext.format_h2("\n ## global metrics")
metrics.collect(mclasses)
- for metric in metrics.metrics do
- if metric isa IntMetric then
- print toolcontext.format_h4("\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ metrics.to_console(1, not toolcontext.opt_nocolors.value)
end
end
end
# The values average
fun avg: Float is abstract
+
+ # Pretty print the metric results in console
+ fun to_console(indent: Int, colors: Bool) do
+ 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
+ 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]})"
+ end
+ end
end
# A Metric that collects integer data
for metric in metrics do metric.collect(elements)
end
+ # Pretty print the resuls in console
+ fun to_console(indent: Int, colors: Bool) do
+ for metric in metrics do metric.to_console(indent, colors)
+ end
+
end
for mproject in model.mprojects do
print toolcontext.format_h2("\n ## project {mproject}")
-
for mgroup in mproject.mgroups do
if mgroup.mmodules.is_empty then continue
# Scalar metrics
print toolcontext.format_h3(" `- group {mgroup.full_name}")
-
mmodules.add_all(mgroup.mmodules)
metrics.collect(new HashSet[MModule].from(mgroup.mmodules))
- for metric in metrics.metrics do
- if metric isa IntMetric then
- print toolcontext.format_h4("\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ metrics.to_console(1, not toolcontext.opt_nocolors.value)
end
end
if not mmodules.is_empty then
print toolcontext.format_h2("\n ## global metrics")
metrics.clear
metrics.collect(mmodules)
- for metric in metrics.metrics do
- if metric isa IntMetric then
- print toolcontext.format_h4( "\t{metric.name}: {metric.desc}")
- print toolcontext.format_p("\t avg: {metric.avg}")
- var max = metric.max
- print toolcontext.format_p("\t max: {max.first} ({max.second})")
- var min = metric.min
- print toolcontext.format_p("\t min: {min.first} ({min.second})")
- end
- end
+ metrics.to_console(1, not toolcontext.opt_nocolors.value)
end
end
end