Skip to content

Commit 6f66936

Browse files
committed
Print profile info
1 parent 724ad5e commit 6f66936

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

‎src/main/java/org/javacs/JavaCompilerService.java‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,36 @@ void walkLocals(Scope s) {
447447
}
448448
}
449449

450+
StringBuilder profile = new StringBuilder();
451+
Instant started = Instant.now();
452+
453+
void profileEnd(Scope s) {
454+
var ended = Instant.now();
455+
var elapsed = Duration.between(started, ended);
456+
var ms = elapsed.getSeconds() * 1000 + elapsed.getNano() / 1000 / 1000;
457+
profile.append("\n\t").append(s);
458+
profile.append(String.format("\n\t\t%dms", ms));
459+
started = ended;
460+
}
461+
462+
void printProfile() {
463+
LOG.info(profile.toString());
464+
}
465+
450466
// Walk each enclosing scope, placing its members into `results`
451467
List<Element> walkScopes() {
452468
// TODO consider limiting how many ancestors we go through, and rely on sourcepath/classpath completions
453469
for (var s = start; s != null; s = s.getEnclosingScope()) {
454470
walkLocals(s);
455-
if (result.size() >= MAX_COMPLETION_ITEMS) return result;
471+
profileEnd(s);
472+
// Return early?
473+
if (result.size() >= MAX_COMPLETION_ITEMS) {
474+
printProfile();
475+
return result;
476+
}
456477
}
457478

479+
printProfile();
458480
return result;
459481
}
460482
}

0 commit comments

Comments
 (0)