nitc :: RTAMetricsPhase :: callsite_info
nitc :: RTAMetricsPhase :: defaultinit
nitc $ RTAMetricsPhase :: SELF
Type of this instance, automatically specialized in every classnitc $ RTAMetricsPhase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: _in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: _toolcontext
The toolcontext instance attached to the phasenitc :: RTAMetricsPhase :: callsite_info
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: Phase :: defaultinit
nitc :: RTAMetricsPhase :: defaultinit
core :: Object :: defaultinit
nitc :: Phase :: in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: in_hierarchy=
The dependence relation of the phase with the other phasescore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: Phase :: process_annotated_node
Specific actions to execute on annotated nodesnitc :: Phase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: process_nclassdef
Specific actions to execute on the tree of a class definitionnitc :: Phase :: process_nmodule
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_nmodule_after
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_npropdef
Specific actions to execute on the tree of a propertynitc :: Phase :: toolcontext
The toolcontext instance attached to the phasenitc :: Phase :: toolcontext=
The toolcontext instance attached to the phase
private class RTAMetricsPhase
super Phase
redef fun process_mainmodule(mainmodule, given_mmodules)
do
if not toolcontext.opt_rta.value and not toolcontext.opt_all.value then return
var csv = toolcontext.opt_csv.value
var out = "{toolcontext.opt_dir.value or else "metrics"}/rta"
out.mkdir
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(min_visibility = protected_visibility)
print toolcontext.format_h1("\n# RTA metrics")
print toolcontext.format_h2("\n ## Live instances by mainmodules")
var mmetrics = new MetricSet
mmetrics.register(new MNLC(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLT(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNCT(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLI(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLM(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLMD(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.register(new MNLDD(model, mainmodule, filter, toolcontext.modelbuilder))
mmetrics.collect(new HashSet[MModule].from([mainmodule]))
mmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then mmetrics.to_csv.write_to_file("{out}/{mainmodule}.csv")
var mtypes = new HashSet[MType]
var analysis = new MetricsRapidTypeAnalysis(toolcontext.modelbuilder, mainmodule)
analysis.run_analysis
mtypes.add_all(analysis.live_types)
mtypes.add_all(analysis.live_cast_types)
print toolcontext.format_h2("\n ## Total live instances by mclasses")
var cmetrics = new MetricSet
cmetrics.register(analysis.cnli)
cmetrics.register(analysis.cnlc)
cmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then cmetrics.to_csv.write_to_file("{out}/mclasses.csv")
print toolcontext.format_h2("\n ## Total live instances by mtypes")
var tmetrics = new MetricSet
tmetrics.register(analysis.tnli)
tmetrics.register(analysis.tnlc)
tmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then tmetrics.to_csv.write_to_file("{out}/mtypes.csv")
print toolcontext.format_h2("\n ## MType complexity")
var gmetrics = new MetricSet
gmetrics.register(new TAGS)
gmetrics.register(new TDGS)
gmetrics.collect(mtypes)
gmetrics.to_console(1, not toolcontext.opt_nocolors.value)
if csv then gmetrics.to_csv.write_to_file("{out}/complexity.csv")
callsite_info(analysis)
# dump type and method infos
if csv then
analysis.live_types_to_csv.write_to_file("{out}/rta_types.csv")
analysis.live_methods_to_tree.write_to_file("{out}/rta_methods.dat")
end
end
fun callsite_info(rta: RapidTypeAnalysis)
do
print toolcontext.format_h2("\n ## Callsites")
print "* {rta.live_callsites.length} live callsites"
var csep = new Counter[MPropDef]
var cglo = new Counter[MPropDef]
var morphisme = new Counter[Int]
for cs in rta.live_callsites do
csep.inc(cs.mpropdef)
var targets = rta.live_targets(cs)
for d in targets do
cglo.inc(d)
end
morphisme.inc(targets.length)
end
print toolcontext.format_h3("MMethodDef locally designated (by number of CallSites)")
csep.print_summary
csep.print_elements(5)
print toolcontext.format_h3("MMethodDef possibly invoked at runtime (by number of CallSites)")
cglo.print_summary
cglo.print_elements(5)
end
end
src/metrics/rta_metrics.nit:31,1--120,3