If you have Simons (in this case Stopwatch-es) in a hierarchy (like
ala, ala.bbb and ala.ccc) than you can calculate their aggregate on
demand with:
// somehow get hold of "ala" Simon, e.g.
Stopwatch ala = SimonManager.getStopwach("ala");
StopwatchAggregate aggregate = SimonUtils.calculateStopwatchAggregate(ala);
It is possible to filter the stopwatches you want using SimonFilter.
Please, check the Javadoc, which states that if Simon is not accepted
by the filter, the whole subtree is not aggregated. BTW, all counters
are ignored by default, as they are of different type but they don't
disrupt aggregation of the subtree, unless they don't match the
filter. You can use Simon attributes to mark those that should be
aggregated:
StopwatchAggregate aggregate =
SimonUtils.calculateStopwatchAggregate(SimonManager.getRootSimon(),
new SimonFilter() {
@Override
public boolean accept(Simon simon) {
return simon.getAttribute("aggregated") != null;
}
});
However currently it is not possible to traverse the hierarchy and
"cherry-pick" only aggregated Simons, because - as said above - if the
simon is not aggregated itself, it stops the aggregation of its
subtree.
Virgo