AffinityGraphBuilder builder = new ZachBuilder();
Properties props = new Properties();
props.put("com.sun.sgs.impl.service.nodemap.affinity.numThreads",
String.valueOf(numThreads));
// third argument true: gather statistics
SingleLabelPropagation lpa =
new SingleLabelPropagation(builder, collector, props);
AffinityGroupFinderMXBean bean = (AffinityGroupFinderMXBean)
collector.getRegisteredMBean(AffinityGroupFinderMXBean.MXBEAN_NAME);
assertNotNull(bean);
bean.clear();
// Be sure the consumer is turned on
collector.getConsumer(AffinityGroupFinderStats.CONS_NAME).
setProfileLevel(ProfileLevel.MAX);
double avgMod = 0.0;
double maxMod = 0.0;
double minMod = 1.0;
for (int i = 0; i < RUNS; i++) {
Set<AffinityGroup> groups =
Objects.uncheckedCast(lpa.findAffinityGroups());
double mod =
AffinityGroupGoodness.calcModularity(
new ZachBuilder().getAffinityGraph(), groups);
avgMod = avgMod + mod;
maxMod = Math.max(maxMod, mod);
minMod = Math.min(minMod, mod);
}
System.out.printf("SING (%d runs, %d threads): " +
"avg time : %4.2f ms, " +
" time range [%d - %d ms] " +
" avg iters : %4.2f, avg modularity: %.4f, " +
" modularity range [%.4f - %.4f] %n",
RUNS, numThreads,
bean.getAvgRunTime(),
bean.getMinRunTime(),
bean.getMaxRunTime(),
bean.getAvgIterations(),
avgMod/(double) RUNS,
minMod, maxMod);
lpa.shutdown();
}