metrics: add poset_metrics
authorJean Privat <jean@pryen.org>
Tue, 23 Jul 2013 15:58:20 +0000 (11:58 -0400)
committerJean Privat <jean@pryen.org>
Tue, 23 Jul 2013 15:58:43 +0000 (11:58 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/metrics/metrics.nit
src/metrics/metrics_base.nit
src/metrics/poset_metrics.nit [new file with mode: 0644]
tests/sav/nitmetrics.res
tests/sav/nitmetrics_args1.res
tests/sav/nitmetrics_args1.sav

index e49fdb5..24936b1 100644 (file)
@@ -27,3 +27,4 @@ import generate_hierarchies
 import rta_metrics
 import model_hyperdoc
 import tables_metrics
+import poset_metrics
index c7e381b..ed2ab9a 100644 (file)
@@ -44,6 +44,8 @@ redef class ToolContext
        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 = "."
@@ -61,6 +63,7 @@ redef class ToolContext
                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
 
diff --git a/src/metrics/poset_metrics.nit b/src/metrics/poset_metrics.nit
new file mode 100644 (file)
index 0000000..8ec89b1
--- /dev/null
@@ -0,0 +1,44 @@
+# 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
index d2fd8eb..820b750 100644 (file)
@@ -20,4 +20,5 @@
   --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
index 5102893..df6d492 100644 (file)
@@ -1,4 +1,158 @@
 *** 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
index 9956c30..f5debff 100644 (file)
@@ -1,4 +1,158 @@
 *** 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