void () { configureFromFileText("Stress.java", text); List<HighlightInfo> oldWarnings = new ArrayList<>(doHighlighting()); Comparator<HighlightInfo> infoComparator = (o1, o2) -> { if (o1.equals(o2)) return 0; if (o1.getActualStartOffset() != o2.getActualStartOffset()) return o1.getActualStartOffset() - o2.getActualStartOffset(); return text(o1).compareTo(text(o2)); }; Collections.sort(oldWarnings, infoComparator); List<String> oldWarningTexts = new ArrayList<>(); for (HighlightInfo info : oldWarnings) { oldWarningTexts.add(text(info)); } Random random = new Random(); DaemonCodeAnalyzer.getInstance(getProject()).restart(); int N = 20; long[] time = new long[N]; int oldWarningSize = oldWarnings.size(); for (int i = 0; i < N; i++) { PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); long start = System.currentTimeMillis(); LOG.debug("i = " + i); String s = getFile().getText(); int offset; while (true) { offset = random.nextInt(s.length()); if (s.charAt(offset) == ' ') break; } getEditor().getCaretModel().moveToOffset(offset); type("/*--*/"); List<HighlightInfo> infos = doHighlighting(); if (oldWarningSize != infos.size()) { infos = new ArrayList<>(infos); Collections.sort(infos, infoComparator); for (int k=0; k<Math.min(infos.size(), oldWarningSize);k++) { HighlightInfo info = infos.get(k); String text = text(info); String oldText = oldWarningTexts.get(k); if (!text.equals(oldText)) { System.err.println(k+"\n"+ "Old: "+oldText+"; info: " + oldWarnings.get(k)+";\n" + "New: "+text+ "; info: " + info); break; } } String oldText = StringUtil.join(oldWarningTexts, "\n"); String newText = StringUtil.join(infos, info->text(info), "\n"); assertEquals(oldText, newText); assertEquals(infos.toString(), oldWarningSize, infos.size()); } for (HighlightInfo info : infos) { assertNotSame(String.valueOf(info), HighlightSeverity.ERROR, info.getSeverity()); } for (int k=0; k<"/*--*/".length();k++) { backspace(); } UIUtil.dispatchAllInvocationEvents(); long end = System.currentTimeMillis(); time[i] = end - start; } FileEditorManagerEx.getInstanceEx(getProject()).closeAllFiles(); System.out.println("Average among the N/3 median times: " + ArrayUtil.averageAmongMedians(time, 3) + "ms"); }