var opt_mmodules = new OptionBool("Compute metrics about mmodules", "--mmodules")
# --mclassses
var opt_mclasses = new OptionBool("Compute metrics about mclasses", "--mclasses")
-
+ # --mendel
+ var opt_mendel = new OptionBool("Compute mendel metrics", "--mendel")
# --inheritance
var opt_inheritance = new OptionBool("Compute metrics about inheritance usage", "--inheritance")
# --genericity
self.option_context.add_option(opt_all)
self.option_context.add_option(opt_mmodules)
self.option_context.add_option(opt_mclasses)
+ self.option_context.add_option(opt_mendel)
self.option_context.add_option(opt_inheritance)
self.option_context.add_option(opt_refinement)
self.option_context.add_option(opt_self)
self.option_context.add_option(opt_nocolors)
end
- redef fun process_options
+ redef fun process_options(args)
do
super
var val = self.opt_dir.value
# Pretty print the metric results in console
fun to_console(indent: Int, colors: Bool) do
+ if values.is_empty then
+ if colors then
+ print "{"\t" * indent}{name}: {desc} -- nothing".green
+ else
+ print "{"\t" * indent}{name}: {desc} -- nothing"
+ end
+ return
+ end
+
var max = self.max
var min = self.min
if colors then
# The values standard derivation
fun std_dev: Float is abstract
+
+ # The element with the highest value
+ fun max: ELM is abstract
+
+ # The element with the lowest value
+ fun min: ELM is abstract
+
+ # The value threshold above what elements are considered as 'interesting'
+ fun threshold: Float do return avg + std_dev
+
+ # The set of element above the threshold
+ fun above_threshold: Set[ELM] is abstract
end
# A Metric that collects integer data
redef fun clear do values_cache.clear
- # Return the couple with the highest value
- fun max: Couple[ELM, Int] do
+ fun sum: Int do return values_cache.sum
+
+ redef fun max do
assert not values_cache.is_empty
- var elem = values_cache.max.as(not null)
- var value = values_cache[elem]
- return new Couple[ELM, Int](elem, value)
+ return values_cache.max.as(not null)
end
- # Return the couple with the lowest value
- fun min: Couple[ELM, Int] do
+ redef fun min do
assert not values_cache.is_empty
- var elem = values_cache.min.as(not null)
- var value = values_cache[elem]
- return new Couple[ELM, Int](elem, value)
+ return values_cache.min.as(not null)
end
# Values average
redef fun avg: Float do return values_cache.avg
redef fun std_dev: Float do return values_cache.std_dev
+
+ redef fun above_threshold do
+ var above = new HashSet[ELM]
+ var threshold = threshold
+ for element, value in values do
+ if value.to_f > threshold then above.add(element)
+ end
+ return above
+ end
+
+ redef fun to_console(indent, colors) do
+ super
+ if colors then
+ print "{"\t" * indent} sum: {sum}".light_gray
+ else
+ print "{"\t" * indent} sum: {sum}"
+ end
+ end
end
# A Metric that collects float datas
redef fun clear do values_cache.clear
- # Return the couple with the highest value
- fun max: Couple[ELM, Float] do
+ fun sum: Float do
+ var sum = 0.0
+ for v in values.values do sum += v
+ return sum
+ end
+
+ redef fun max do
assert not values.is_empty
var max: nullable Float = null
var elem: nullable ELM = null
elem = e
end
end
- return new Couple[ELM, Float](elem.as(not null), max.as(not null))
+ return elem.as(not null)
end
- # Return the couple with the lowest value
- fun min: Couple[ELM, Float] do
+ redef fun min do
assert not values.is_empty
var min: nullable Float = null
var elem: nullable ELM = null
elem = e
end
end
- return new Couple[ELM, Float](elem.as(not null), min.as(not null))
+ return elem.as(not null)
end
redef fun avg do
if values.is_empty then return 0.0
- var sum = 0.0
- for value in values.values do
- sum += value
- end
return sum / values.length.to_f
end
end
return (sum / values.length.to_f).sqrt
end
+
+ redef fun above_threshold do
+ var above = new HashSet[ELM]
+ var threshold = threshold
+ for element, value in values do
+ if value > threshold then above.add(element)
+ end
+ return above
+ end
+
+ redef fun to_console(indent, colors) do
+ super
+ if colors then
+ print "{"\t" * indent} sum: {sum}".light_gray
+ else
+ print "{"\t" * indent} sum: {sum}"
+ end
+ end
+
end
# A MetricSet is a metric holder