void (@NonNls final String source, @NonNls @Nullable final String tree) { final PsiJavaFile file = (PsiJavaFile)createLightFile("test.java", source); final FileASTNode fileNode = file.getNode(); assertNotNull(fileNode); assertFalse(fileNode.isParsed()); long t1 = System.nanoTime(); final StubElement lighterTree = NEW_BUILDER.buildStubTree(file); t1 = Math.max((System.nanoTime() - t1)/1000, 1); assertFalse(fileNode.isParsed()); file.getNode().getChildren(null); // force switch to AST long t2 = System.nanoTime(); final StubElement lighterTree2 = NEW_BUILDER.buildStubTree(file); // build over AST t2 = Math.max((System.nanoTime() - t2)/1000, 1); file.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { assert !(element instanceof PsiErrorElement) : element; super.visitElement(element); } }); final String lightStr = DebugUtil.stubTreeToString(lighterTree); final String lightStr2 = DebugUtil.stubTreeToString(lighterTree2); if (tree != null) { System.out.println("light=" + t1 + "mks, heavy=" + t2 + "mks"); if (!tree.isEmpty()) { assertEquals("light tree differs", tree, lightStr); assertEquals("light tree (2nd) differs", tree, lightStr2); } } }