import rta_metrics
import model_hyperdoc
import tables_metrics
+import poset_metrics
var opt_generate_csv = new OptionBool("Generate CVS format metrics", "--generate-csv")
# --generate_hyperdoc
var opt_generate_hyperdoc = new OptionBool("Generate Hyperdoc", "--generate_hyperdoc")
+ # --poset
+ var opt_poset = new OptionBool("Complete metrics on posets", "--poset")
var opt_dir = new OptionString("Directory where some statistics files are generated", "-d", "--dir")
var output_dir: String = "."
self.option_context.add_option(opt_rta)
self.option_context.add_option(opt_generate_csv)
self.option_context.add_option(opt_generate_hyperdoc)
+ self.option_context.add_option(opt_poset)
self.option_context.add_option(opt_dir)
end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Metrics about the various posets of the model of a Nit program
+module poset_metrics
+
+import poset
+import metrics_base
+import frontend
+
+redef class ToolContext
+ var poset_metrics_phase: Phase = new PosetMetricsPhase(self, null)
+end
+
+private class PosetMetricsPhase
+ super Phase
+
+ redef fun process_mainmodule(mainmodule)
+ do
+ if not toolcontext.opt_poset.value and not toolcontext.opt_all.value then return
+
+ var model = mainmodule.model
+ print "--- Poset metrics ---"
+ print "## Module importation hierarchy"
+ model.mmodule_importation_hierarchy.print_metrics
+ print "## Module nesting hierarchy"
+ model.mmodule_nesting_hierarchy.print_metrics
+ print "## Classdef hierarchy"
+ model.mclassdef_hierarchy.print_metrics
+ print "## Class hierarchy"
+ mainmodule.flatten_mclass_hierarchy.print_metrics
+ end
+end
--rta Compute RTA metrics
--generate-csv Generate CVS format metrics
--generate_hyperdoc Generate Hyperdoc
+ --poset Complete metrics on posets
-d, --dir Directory where some statistics files are generated
*** METRICS ***
+--- Poset metrics ---
+## Module importation hierarchy
+Number of nodes: 1
+Number of edges: 1 (1.00 per node)
+Number of direct edges: 0 (0.0 per node)
+Distribution of greaters
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct greaters
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+Distribution of smallers
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct smallers
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+## Module nesting hierarchy
+Number of nodes: 1
+Number of edges: 1 (1.00 per node)
+Number of direct edges: 0 (0.0 per node)
+Distribution of greaters
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct greaters
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+Distribution of smallers
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct smallers
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+## Classdef hierarchy
+Number of nodes: 8
+Number of edges: 22 (2.75 per node)
+Number of direct edges: 7 (0.87 per node)
+Distribution of greaters
+ population: 8
+ minimum value: 2
+ maximum value: 3
+ total value: 22
+ average value: 2.75
+ distribution:
+ <=2: sub-population=2 (25.00%); cumulated value=4 (18.18%)
+ <=4: sub-population=6 (75.00%); cumulated value=18 (81.81%)
+Distribution of direct greaters
+ population: 8
+ minimum value: 0
+ maximum value: 1
+ total value: 7
+ average value: 0.87
+ distribution:
+ <=0: sub-population=1 (12.50%); cumulated value=0 (0.0%)
+ <=1: sub-population=7 (87.50%); cumulated value=7 (100.00%)
+Distribution of smallers
+ population: 8
+ minimum value: 1
+ maximum value: 8
+ total value: 22
+ average value: 2.75
+ distribution:
+ <=1: sub-population=6 (75.00%); cumulated value=6 (27.27%)
+ <=8: sub-population=2 (25.00%); cumulated value=16 (72.72%)
+Distribution of direct smallers
+ population: 8
+ minimum value: 0
+ maximum value: 6
+ total value: 7
+ average value: 0.87
+ distribution:
+ <=0: sub-population=6 (75.00%); cumulated value=0 (0.0%)
+ <=1: sub-population=1 (12.50%); cumulated value=1 (14.28%)
+ <=8: sub-population=1 (12.50%); cumulated value=6 (85.71%)
+## Class hierarchy
+Number of nodes: 7
+Number of edges: 13 (1.85 per node)
+Number of direct edges: 6 (0.85 per node)
+Distribution of greaters
+ population: 7
+ minimum value: 1
+ maximum value: 2
+ total value: 13
+ average value: 1.85
+ distribution:
+ <=1: sub-population=1 (14.28%); cumulated value=1 (7.69%)
+ <=2: sub-population=6 (85.71%); cumulated value=12 (92.30%)
+Distribution of direct greaters
+ population: 7
+ minimum value: 0
+ maximum value: 1
+ total value: 6
+ average value: 0.85
+ distribution:
+ <=0: sub-population=1 (14.28%); cumulated value=0 (0.0%)
+ <=1: sub-population=6 (85.71%); cumulated value=6 (100.00%)
+Distribution of smallers
+ population: 7
+ minimum value: 1
+ maximum value: 7
+ total value: 13
+ average value: 1.85
+ distribution:
+ <=1: sub-population=6 (85.71%); cumulated value=6 (46.15%)
+ <=8: sub-population=1 (14.28%); cumulated value=7 (53.84%)
+Distribution of direct smallers
+ population: 7
+ minimum value: 0
+ maximum value: 6
+ total value: 6
+ average value: 0.85
+ distribution:
+ <=0: sub-population=6 (85.71%); cumulated value=0 (0.0%)
+ <=8: sub-population=1 (14.28%); cumulated value=6 (100.00%)
--- Global Summary metrics ---
(NMD) Number of Modules: 1
(NC) Number of Classes: 4
*** METRICS ***
+--- Poset metrics ---
+## Module importation hierarchy
+Number of nodes: 1
+Number of edges: 1 (1.00 per node)
+Number of direct edges: 0 (0.0 per node)
+Distribution of greaters
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct greaters
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+Distribution of smallers
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct smallers
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+## Module nesting hierarchy
+Number of nodes: 1
+Number of edges: 1 (1.00 per node)
+Number of direct edges: 0 (0.0 per node)
+Distribution of greaters
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct greaters
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+Distribution of smallers
+ population: 1
+ minimum value: 1
+ maximum value: 1
+ total value: 1
+ average value: 1.00
+ distribution:
+ <=1: sub-population=1 (100.00%); cumulated value=1 (100.00%)
+Distribution of direct smallers
+ population: 1
+ minimum value: 0
+ maximum value: 0
+ total value: 0
+ average value: 0.0
+ distribution:
+ <=0: sub-population=1 (100.00%); cumulated value=0 (na%)
+## Classdef hierarchy
+Number of nodes: 8
+Number of edges: 22 (2.75 per node)
+Number of direct edges: 7 (0.87 per node)
+Distribution of greaters
+ population: 8
+ minimum value: 2
+ maximum value: 3
+ total value: 22
+ average value: 2.75
+ distribution:
+ <=2: sub-population=2 (25.00%); cumulated value=4 (18.18%)
+ <=4: sub-population=6 (75.00%); cumulated value=18 (81.81%)
+Distribution of direct greaters
+ population: 8
+ minimum value: 0
+ maximum value: 1
+ total value: 7
+ average value: 0.87
+ distribution:
+ <=0: sub-population=1 (12.50%); cumulated value=0 (0.0%)
+ <=1: sub-population=7 (87.50%); cumulated value=7 (100.00%)
+Distribution of smallers
+ population: 8
+ minimum value: 1
+ maximum value: 8
+ total value: 22
+ average value: 2.75
+ distribution:
+ <=1: sub-population=6 (75.00%); cumulated value=6 (27.27%)
+ <=8: sub-population=2 (25.00%); cumulated value=16 (72.72%)
+Distribution of direct smallers
+ population: 8
+ minimum value: 0
+ maximum value: 6
+ total value: 7
+ average value: 0.87
+ distribution:
+ <=0: sub-population=6 (75.00%); cumulated value=0 (0.0%)
+ <=1: sub-population=1 (12.50%); cumulated value=1 (14.28%)
+ <=8: sub-population=1 (12.50%); cumulated value=6 (85.71%)
+## Class hierarchy
+Number of nodes: 7
+Number of edges: 13 (1.85 per node)
+Number of direct edges: 6 (0.85 per node)
+Distribution of greaters
+ population: 7
+ minimum value: 1
+ maximum value: 2
+ total value: 13
+ average value: 1.85
+ distribution:
+ <=1: sub-population=1 (14.28%); cumulated value=1 (7.69%)
+ <=2: sub-population=6 (85.71%); cumulated value=12 (92.30%)
+Distribution of direct greaters
+ population: 7
+ minimum value: 0
+ maximum value: 1
+ total value: 6
+ average value: 0.85
+ distribution:
+ <=0: sub-population=1 (14.28%); cumulated value=0 (0.0%)
+ <=1: sub-population=6 (85.71%); cumulated value=6 (100.00%)
+Distribution of smallers
+ population: 7
+ minimum value: 1
+ maximum value: 7
+ total value: 13
+ average value: 1.85
+ distribution:
+ <=1: sub-population=6 (85.71%); cumulated value=6 (46.15%)
+ <=8: sub-population=1 (14.28%); cumulated value=7 (53.84%)
+Distribution of direct smallers
+ population: 7
+ minimum value: 0
+ maximum value: 6
+ total value: 6
+ average value: 0.85
+ distribution:
+ <=0: sub-population=6 (85.71%); cumulated value=0 (0.0%)
+ <=8: sub-population=1 (14.28%); cumulated value=6 (100.00%)
--- Construction of tables ---
Number of runtime classes: 6 (excluding interfaces and abstract classes)
Average number of composing class definition by runtime class: 3.00