List<Integer> counters = new ArrayList<Integer>();
// Generate some initial data
for (int i = 0; i < 10000; i++) {
MethodCallCounterRecord rec = new MethodCallCounterRecord(
r.nextInt(1500000) + 1, r.nextInt(1500000) + 2, r.nextInt(1500000) + 3, r.nextInt(10) + 1);
recs.add(rec);
counters.add(0);
}
MethodCallCounter mcc = new MethodCallCounter();
// Fill in method call counter
while (true) {
int incs = 0;
for (int i = 0; i < recs.size(); i++) {
MethodCallCounterRecord rec = recs.get(i);
if (counters.get(i) < rec.getnCalls()) {
mcc.logCall(rec.getClassId(), rec.getMethodId(), rec.getSignatureId(), 10L);
counters.set(i, counters.get(i) + 1);
incs++;
}
}
if (incs == 0) {
break;
}
}
Set<MethodCallCounterRecord> results = new HashSet<MethodCallCounterRecord>();
results.addAll(mcc.getRecords());
// Indicate (potential) errors
for (MethodCallCounterRecord mcr : recs) {
if (!results.contains(mcr)) {
MethodCallCounterRecord mcrr = null;
for (MethodCallCounterRecord mcr2 : results) {
if (mcr2.getClassId() == mcr.getClassId() && mcr2.getMethodId() == mcr.getMethodId()
&& mcr2.getSignatureId() == mcr.getSignatureId()) {
mcrr = mcr2;
break;