#res.sort !cmp a, b = map[a] <=> map[b]
return res
end
+
+ # Display statistical information
+ fun print_summary
+ do
+ var list = self.sort
+ print " population: {list.length}"
+ if list.is_empty then return
+ print " minimum value: {self[list.first]}"
+ print " maximum value: {self[list.last]}"
+ print " total value: {self.total}"
+ print " average value: {div(self.total,list.length)}"
+ print " distribution:"
+ var count = 0
+ var sum = 0
+ var limit = self[list.first]
+ for t in list do
+ if self[t] > limit then
+ print " <={limit}: sub-population={count} ({div(count*100,list.length)}%); cumulated value={sum} ({div(sum*100,self.total)}%)"
+ count = 0
+ sum = 0
+ while self[t] > limit do
+ limit = limit * 2
+ if limit == 0 then limit = 1
+ end
+ end
+ count += 1
+ sum += self[t]
+ end
+ print " <={limit}: sub-population={count} ({div(count*100,list.length)}%); cumulated value={sum} ({div(sum*100,self.total)}%)"
+ end
end
private class CounterSorter[E: Object]
print " {t}: {typecount[t]}"
end
- # Compute the distribution of type usage
- print "Distribution of type usage:"
- var count = 0
- var sum = 0
- var limit = 1
- for t in types do
- if typecount[t] > limit then
- print " <={limit}: {count} ({div(count*100,types.length)}% of types; {div(sum*100,typecount.total)}% of usage)"
- count = 0
- sum = 0
- while typecount[t] > limit do limit = limit * 2
- end
- count += 1
- sum += typecount[t]
- end
- print " <={limit}: {count} ({div(count*100,types.length)}% of types; {div(sum*100,typecount.total)}% of usage)"
+ # Some statistics
+ print "Statistics of type usage:"
+ typecount.print_summary
end
C: 1
B: 1
A: 1
-Distribution of type usage:
- <=1: 3 (75.00% of types; 33.33% of usage)
- <=8: 1 (25.00% of types; 66.66% of usage)
+Statistics of type usage:
+ population: 4
+ minimum value: 1
+ maximum value: 6
+ total value: 9
+ average value: 2.25
+ distribution:
+ <=1: sub-population=3 (75.00%); cumulated value=3 (33.33%)
+ <=8: sub-population=1 (25.00%); cumulated value=6 (66.66%)
--- Sends on Nullable Reciever ---
Total number of sends: 19
Number of sends on a nullable receiver: 0 (0.0%)
C: 1
B: 1
A: 1
-Distribution of type usage:
- <=1: 3 (75.00% of types; 33.33% of usage)
- <=8: 1 (25.00% of types; 66.66% of usage)
+Statistics of type usage:
+ population: 4
+ minimum value: 1
+ maximum value: 6
+ total value: 9
+ average value: 2.25
+ distribution:
+ <=1: sub-population=3 (75.00%); cumulated value=3 (33.33%)
+ <=8: sub-population=1 (25.00%); cumulated value=6 (66.66%)
--- Metrics of refinement usage ---
Number of modules: 1