1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2012 Jean Privat <jean@pryen.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # General statistics on a model
21 private import metrics_base
23 # Print general statistics on a model
24 fun compute_statistics
(model
: Model)
26 print
"--- Statistics of the model ---"
27 var nbmod
= model
.mmodules
.length
28 print
"Number of modules: {nbmod}"
32 var nbcla
= model
.mclasses
.length
33 var nbcladef
= model
.mclassdef_hierarchy
.length
34 print
"Number of classes: {nbcla}"
36 # determine the distribution of:
37 # * class kinds (interface, abstract class, etc.)
38 # * refinex classes (vs. unrefined ones)
39 var kinds
= new Counter[MClassKind]
41 for c
in model
.mclasses
do
43 if c
.mclassdefs
.length
> 1 then
47 for k
in kinds
.sort
do
49 print
" Number of {k} kind: {v} ({div(v*100,nbcla)}%)"
55 print
"Number of class definitions: {nbcladef}"
56 print
"Number of refined classes: {refined} ({div(refined*100,nbcla)}%)"
57 print
"Average number of class refinments by classes: {div(nbcladef-nbcla,nbcla)}"
58 print
"Average number of class refinments by refined classes: {div(nbcladef-nbcla,refined)}"
62 var nbprop
= model
.mproperties
.length
65 print
"Number of properties: {model.mproperties.length}"
66 var pkinds
= new Counter[String]
67 for p
in model
.mproperties
do
68 nbpropdef
+= p
.mpropdefs
.length
69 if p
.mpropdefs
.length
> 1 then
72 pkinds
.inc
(p
.class_name
)
74 for k
in pkinds
.sort
do
76 print
" Number of {k}: {v} ({div(v*100,nbprop)}%)"
81 print
"Number of property definitions: {nbpropdef}"
82 print
"Number of redefined properties: {redefined} ({div(redefined*100,nbprop)}%)"
83 print
"Average number of property redefinitions by property: {div(nbpropdef-nbprop,nbprop)}"
84 print
"Average number of property redefinitions by redefined property: {div(nbpropdef-nbprop,redefined)}"