X-Git-Url: http://nitlanguage.org diff --git a/src/metrics/static_types_metrics.nit b/src/metrics/static_types_metrics.nit index 9986f13..5c77c0e 100644 --- a/src/metrics/static_types_metrics.nit +++ b/src/metrics/static_types_metrics.nit @@ -19,6 +19,21 @@ module static_types_metrics private import metrics_base import modelbuilder +import modelize_class +import frontend + +redef class ToolContext + var static_types_metrics_phase = new StaticTypesMetricsPhase(self, null) +end + +private class StaticTypesMetricsPhase + super Phase + redef fun process_mainmodule(mainmodule) + do + if not toolcontext.opt_static_types.value and not toolcontext.opt_all.value then return + compute_static_types_metrics(toolcontext.modelbuilder) + end +end # The job of this visitor is to resolve all types found private class ATypeCounterVisitor @@ -79,20 +94,7 @@ do print " {t}: {typecount[t]}" end - # Compute the distribution of type usage - print "Distribution of type usage:" - var count = 0 - var sum = 0 - var limit = 1 - for t in types do - if typecount[t] > limit then - print " <={limit}: {count} ({div(count*100,types.length)}% of types; {div(sum*100,typecount.total)}% of usage)" - count = 0 - sum = 0 - while typecount[t] > limit do limit = limit * 2 - end - count += 1 - sum += typecount[t] - end - print " <={limit}: {count} ({div(count*100,types.length)}% of types; {div(sum*100,typecount.total)}% of usage)" + # Some statistics + print "Statistics of type usage:" + typecount.print_summary end