com.intellij.testFramework.PlatformTestUtil Java Examples
The following examples show how to use
com.intellij.testFramework.PlatformTestUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BashPerformanceTest.java From BashSupport with Apache License 2.0 | 6 votes |
private void doTest(final int iterations) { myFixture.configureByFile("functions_issue96.bash"); enableInspections(); long start = System.currentTimeMillis(); PlatformTestUtil.startPerformanceTest(getTestName(true), iterations * 2000, () -> { for (int i = 0; i < iterations; i++) { long innerStart = System.currentTimeMillis(); Editor editor = myFixture.getEditor(); editor.getCaretModel().moveToOffset(editor.getDocument().getTextLength()); myFixture.type("\n"); myFixture.type("echo \"hello world\"\n"); myFixture.type("pri"); myFixture.complete(CompletionType.BASIC); System.out.println("Cycle duration: " + (System.currentTimeMillis() - innerStart)); } }).usesAllCPUCores().attempts(1).assertTiming(); System.out.println("Complete duration: " + (System.currentTimeMillis() - start)); }
Example #2
Source File: TokenSetTest.java From consulo with Apache License 2.0 | 6 votes |
@Test public void performance() throws Exception { final IElementType[] elementTypes = IElementType.enumerate(CommonProcessors.<IElementType>alwaysTrue()); final TokenSet set = TokenSet.create(); final int shift = new Random().nextInt(500000); PlatformTestUtil.startPerformanceTest("TokenSet.contains() performance", 25, new ThrowableRunnable() { @Override public void run() throws Throwable { for (int i = 0; i < 1000000; i++) { final IElementType next = elementTypes[((i + shift) % elementTypes.length)]; assertFalse(set.contains(next)); } } }).cpuBound().assertTiming(); }
Example #3
Source File: RangeMarkerTest.java From consulo with Apache License 2.0 | 6 votes |
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception { final int N = 50000; Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N)); final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true); for (int i=0; i<N-1;i++) { markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE); } markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE); PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() { @Override public void run() { List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>(); CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list); for (int i=0; i<N-1;i++) { list.clear(); markupModel.processRangeHighlightersOverlappingWith(2*i, 2*i+1, coll); assertEquals(2, list.size()); // 1 line plus one exact range marker } } }).assertTiming(); }
Example #4
Source File: VirtualFilePointerTest.java From consulo with Apache License 2.0 | 6 votes |
public void testManyPointersUpdatePerformance() throws IOException { LoggingListener listener = new LoggingListener(); final List<VFileEvent> events = new ArrayList<VFileEvent>(); final File ioTempDir = createTempDirectory(); final VirtualFile temp = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioTempDir); for (int i=0; i<100000; i++) { myVirtualFilePointerManager.create(VfsUtilCore.pathToUrl("/a/b/c/d/" + i), disposable, listener); String name = "xxx" + (i % 20); events.add(new VFileCreateEvent(this, temp, name, true, null, null, true, null)); } PlatformTestUtil.startPerformanceTest("vfp update", 10000, new ThrowableRunnable() { @Override public void run() throws Throwable { for (int i=0; i<100; i++) { // simulate VFS refresh events since launching the actual refresh is too slow AsyncFileListener.ChangeApplier applier = myVirtualFilePointerManager.prepareChange(events); applier.beforeVfsChange(); applier.afterVfsChange(); } } }).assertTiming(); }
Example #5
Source File: GetPathPerformanceTest.java From consulo with Apache License 2.0 | 6 votes |
public void testGetPath() throws IOException, InterruptedException { final File dir = FileUtil.createTempDirectory("GetPath",""); dir.deleteOnExit(); String path = dir.getPath() + StringUtil.repeat("/xxx", 50) + "/fff.txt"; File ioFile = new File(path); boolean b = ioFile.getParentFile().mkdirs(); assertTrue(b); boolean c = ioFile.createNewFile(); assertTrue(c); final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(ioFile.getPath().replace(File.separatorChar, '/')); assertNotNull(file); PlatformTestUtil.startPerformanceTest("VF.getPath() performance failed", 4000, new ThrowableRunnable() { @Override public void run() { for (int i = 0; i < 1000000; ++i) { file.getPath(); } } }).cpuBound().assertTiming(); }
Example #6
Source File: LocalFileSystemTest.java From consulo with Apache License 2.0 | 6 votes |
public void testCopyDir() throws Exception { File fromDir = createTempDirectory(); File toDir = createTempDirectory(); VirtualFile fromVDir = myFS.findFileByPath(fromDir.getPath().replace(File.separatorChar, '/')); VirtualFile toVDir = myFS.findFileByPath(toDir.getPath().replace(File.separatorChar, '/')); assertNotNull(fromVDir); assertNotNull(toVDir); final VirtualFile dirToCopy = fromVDir.createChildDirectory(this, "dir"); final VirtualFile file = dirToCopy.createChildData(this, "temp_file"); file.setBinaryContent(new byte[]{0, 1, 2, 3}); final String newName = "dir"; final VirtualFile dirCopy = dirToCopy.copy(this, toVDir, newName); assertEquals(newName, dirCopy.getName()); PlatformTestUtil.assertDirectoriesEqual(toVDir, fromVDir); }
Example #7
Source File: TestCaseLoader.java From consulo with Apache License 2.0 | 5 votes |
void addClassIfTestCase(Class testCaseClass) { if (shouldAddTestCase(testCaseClass, true) && testCaseClass != myFirstTestClass && testCaseClass != myLastTestClass && PlatformTestUtil.canRunTest(testCaseClass)) { myClassList.add(testCaseClass); } }
Example #8
Source File: StringEnumeratorTest.java From consulo with Apache License 2.0 | 5 votes |
public void testPerformance() throws IOException { final IntObjectCache<String> stringCache = new IntObjectCache<String>(2000); final IntObjectCache.DeletedPairsListener listener = new IntObjectCache.DeletedPairsListener() { @Override public void objectRemoved(final int key, final Object value) { try { assertEquals(myEnumerator.enumerate((String)value), key); } catch (IOException e) { throw new RuntimeException(e); } } }; PlatformTestUtil.startPerformanceTest("PersistentStringEnumerator performance failed", 2500, new ThrowableRunnable() { @Override public void run() throws Exception { stringCache.addDeletedPairsListener(listener); for (int i = 0; i < 100000; ++i) { final String string = createRandomString(); stringCache.cacheObject(myEnumerator.enumerate(string), string); } stringCache.removeDeletedPairsListener(listener); stringCache.removeAll(); } }).cpuBound().assertTiming(); myEnumerator.close(); System.out.printf("File size = %d bytes\n", myFile.length()); }
Example #9
Source File: BTreeEnumeratorTest.java From consulo with Apache License 2.0 | 5 votes |
public void testPerformance() throws IOException { final IntObjectCache<String> stringCache = new IntObjectCache<String>(2000); final IntObjectCache.DeletedPairsListener listener = new IntObjectCache.DeletedPairsListener() { @Override public void objectRemoved(final int key, final Object value) { try { assertEquals(myEnumerator.enumerate((String)value), key); } catch (IOException e) { throw new RuntimeException(e); } } }; PlatformTestUtil.startPerformanceTest("PersistentStringEnumerator performance failed", 2500, new ThrowableRunnable() { @Override public void run() throws Exception { stringCache.addDeletedPairsListener(listener); for (int i = 0; i < 100000; ++i) { final String string = createRandomString(); stringCache.cacheObject(myEnumerator.enumerate(string), string); } stringCache.removeDeletedPairsListener(listener); stringCache.removeAll(); } }).assertTiming(); myEnumerator.close(); System.out.printf("File size = %d bytes\n", myFile.length()); }
Example #10
Source File: StringBuilderSpinAllocatorTest.java From consulo with Apache License 2.0 | 5 votes |
public void testConcurrentPerformance() { assumeTrue(!PlatformTestUtil.COVERAGE_ENABLED_BUILD); for (int i=0; i<10; i++) { long spinTime = concurrentTime(count/THREADS, spinAlloc); long regularTime = concurrentTime(count/THREADS, regularAlloc); System.out.println("concurrent regular: " + regularTime + "; spin :" +spinTime+"; ratio: "+(10*spinTime/regularTime)/10.0+" times"); } }
Example #11
Source File: StringBuilderSpinAllocatorTest.java From consulo with Apache License 2.0 | 5 votes |
public void testSequentialPerformance() { assumeTrue(!PlatformTestUtil.COVERAGE_ENABLED_BUILD); for (int i=0; i<10; i++) { long spinTime = time(count, spinAlloc); long regularTime = time(count, regularAlloc); System.out.println("regular: " + regularTime + "; spin :" +spinTime+"; ratio: "+(10*spinTime/regularTime)/10.0+" times"); } }
Example #12
Source File: StructureViewTest.java From protobuf-jetbrains-plugin with Apache License 2.0 | 5 votes |
private void doTest(final String expected, final boolean showFields) { myFixture.testStructureView(component -> { component.setActionActive("SHOW_FIELDS", showFields); PlatformTestUtil.waitWhileBusy(component.getTree()); assertTreeEqual(component.getTree(), expected); }); }
Example #13
Source File: FileNameSplittingTest.java From consulo with Apache License 2.0 | 5 votes |
public void testPerformance() { myPolicy = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR; PlatformTestUtil.startPerformanceTest("FileNameSplitting performance", 70, new ThrowableRunnable() { @Override public void run() throws Exception { for (int i = 0; i < 100; i++) { for (int j = 0; j < FILE.getPath().length(); j++) myPolicy.getPresentableName(FILE, j); } } }).cpuBound().assertTiming(); }
Example #14
Source File: BashSyntaxHighlighterPerformanceTest.java From BashSupport with Apache License 2.0 | 5 votes |
@Test @Ignore public void testHighlightingPerformanceLarge() throws Exception { PlatformTestUtil.startPerformanceTest(getTestName(true), 10 * 2000, new ThrowableRunnable() { @Override public void run() throws Throwable { doPerformanceTest("functions_issue96.bash", 10, 2000.0); } }).usesAllCPUCores().usesAllCPUCores().assertTiming(); // With tuning: // Finished highlighting 10/10, avg: 20538,100000 ms, min: 18969 ms, max: 22855 ms }
Example #15
Source File: StringUtilPerformanceTest.java From consulo with Apache License 2.0 | 5 votes |
@Test @Ignore public void containsAnyChar() throws Exception { assertTrue(StringUtil.containsAnyChar(TEST_STRING, Integer.toString(new Random().nextInt()))); PlatformTestUtil.startPerformanceTest("StringUtil.containsAnyChar()", SystemInfo.isWindows ? 500 : 200, new ThrowableRunnable() { @Override public void run() throws Throwable { for (int i = 0; i < 1000000; i++) { StringUtil.containsAnyChar(TEST_STRING, "XYZ"); StringUtil.containsAnyChar("XYZ", TEST_STRING); } } }).cpuBound().assertTiming(); }
Example #16
Source File: VfsUtilTest.java From consulo with Apache License 2.0 | 5 votes |
public void testFindRootPerformance() throws Exception { File tempDir = WriteAction.compute(() -> { File res = createTempDirectory(); new File(res, "x.jar").createNewFile(); return res; }); final VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir); final VirtualFile jar = vDir.findChild("x.jar"); assertNotNull(jar); final NewVirtualFile root = ManagingFS.getInstance().findRoot(jar.getPath() + "!/", (NewVirtualFileSystem)StandardFileSystems.jar()); PlatformTestUtil.startPerformanceTest("find root is slow", 500, new ThrowableRunnable() { @Override public void run() throws Throwable { final String path = jar.getPath() + "!/"; final NewVirtualFileSystem fileSystem = (NewVirtualFileSystem)StandardFileSystems.jar(); JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Collections.nCopies(500, null), null, false, new Processor<Object>() { @Override public boolean process(Object o) { for (int i = 0; i < 1000; i++) { NewVirtualFile rootJar = ManagingFS.getInstance().findRoot(path, fileSystem); assertNotNull(rootJar); assertSame(root, rootJar); } return true; } }); } }).assertTiming(); }
Example #17
Source File: VfsUtilTest.java From consulo with Apache License 2.0 | 5 votes |
public void testFindChildByNamePerformance() throws IOException { File tempDir = WriteAction.compute(() -> { File res = createTempDirectory(); return res; }); final VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir); assertNotNull(vDir); assertTrue(vDir.isDirectory()); for (int i = 0; i < 10000; i++) { final String name = i + ".txt"; new WriteCommandAction.Simple(getProject()) { @Override protected void run() throws Throwable { vDir.createChildData(vDir, name); } }.execute().throwException(); } final VirtualFile theChild = vDir.findChild("5111.txt"); PlatformTestUtil.startPerformanceTest("find child is slow", 450, new ThrowableRunnable() { @Override public void run() throws Throwable { for (int i = 0; i < 1000000; i++) { VirtualFile child = vDir.findChild("5111.txt"); assertSame(theChild, child); } } }).assertTiming(); }
Example #18
Source File: VirtualFilePointerTest.java From consulo with Apache License 2.0 | 5 votes |
public void testMultipleCreationOfTheSamePointerPerformance() throws IOException { final LoggingListener listener = new LoggingListener(); final VirtualFilePointer thePointer = myVirtualFilePointerManager.create(VfsUtilCore.pathToUrl("/a/b/c/d/e"), disposable, listener); TempFileSystem.getInstance(); PlatformTestUtil.startPerformanceTest("same url vfp create", 500, new ThrowableRunnable() { @Override public void run() throws Throwable { for (int i=0; i<1000000; i++) { VirtualFilePointer pointer = myVirtualFilePointerManager.create(VfsUtilCore.pathToUrl("/a/b/c/d/e"), disposable, listener); assertSame(pointer, thePointer); } } }).assertTiming(); }
Example #19
Source File: BashSyntaxHighlighterPerformanceTest.java From BashSupport with Apache License 2.0 | 5 votes |
@Test public void testHighlightingPerformanceSmall() throws Exception { PlatformTestUtil.startPerformanceTest(getTestName(true), 35 * 500, new ThrowableRunnable() { @Override public void run() throws Throwable { //Average: 550.4 ms doPerformanceTest("AlsaUtils.bash", 35, 500.0); } }).usesAllCPUCores().usesAllCPUCores().assertTiming(); }
Example #20
Source File: VirtualFilePointerTest.java From consulo with Apache License 2.0 | 5 votes |
public void testContainerCreateDeletePerformance() throws Exception { PlatformTestUtil.startPerformanceTest("VF container create/delete",200, new ThrowableRunnable() { @Override public void run() throws Exception { Disposable parent = Disposable.newDisposable(); for (int i = 0; i < 10000; i++) { myVirtualFilePointerManager.createContainer(parent); } Disposer.dispose(parent); } }).cpuBound().assertTiming(); }
Example #21
Source File: BashFoldingBuilderPerformanceTest.java From BashSupport with Apache License 2.0 | 5 votes |
public void testFolding() { myFixture.configureByFile("functions_issue96.bash"); myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getTextLength()); PlatformTestUtil.startPerformanceTest(getTestName(true), 10 * 250, () -> { for (int i = 0; i < 10; i++) { long start = System.currentTimeMillis(); CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myFixture.getEditor()); myFixture.type("echo hello world\n"); System.out.printf("Cycle duration: %d\n", System.currentTimeMillis() - start); } }).usesAllCPUCores().assertTiming(); }
Example #22
Source File: PerformanceTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void testFieldDefaults() { final String testName = getTestName(true); loadToPsiFile("/performance/" + testName + "/lombok.config"); final PsiFile psiFile = loadToPsiFile("/performance/" + testName + "/HugeClass.java"); PlatformTestUtil.startPerformanceTest(getTestName(false), 500, () -> { type(' '); PsiDocumentManager.getInstance(getProject()).commitDocument(getEditor().getDocument()); ((PsiJavaFileImpl) psiFile).getClasses()[0].getFields()[0].hasModifierProperty(PsiModifier.FINAL); backspace(); PsiDocumentManager.getInstance(getProject()).commitDocument(getEditor().getDocument()); ((PsiJavaFileImpl) psiFile).getClasses()[0].getFields()[0].hasModifierProperty(PsiModifier.FINAL); }).assertTiming(); }
Example #23
Source File: SmartTreeStructureTest.java From consulo with Apache License 2.0 | 5 votes |
public void testFiltering() throws Exception { myModel.addFlter(new Filter() { @Override @Nonnull public ActionPresentation getPresentation() { throw new RuntimeException(); } @Override @Nonnull public String getName() { throw new RuntimeException(); } @Override public boolean isVisible(TreeElement treeNode) { return !treeNode.toString().contains("a"); } @Override public boolean isReverted() { return false; } }); assertStructureEqual("root\n" + ".Group:b\n" + "..Group:d\n" + "...bcd\n" + "....Group:b\n" + ".....bhg_yt\n" + "..Group:f\n" + "...bft\n" + "....ttt\n" + ".Group:d\n" + "..eed\n" + "...zzz\n" + ".xxx\n" + ".xxx\n", PlatformTestUtil.createComparator(myPrintInfo)); }
Example #24
Source File: SmartTreeStructureTest.java From consulo with Apache License 2.0 | 5 votes |
public void testGrouping() throws Exception { assertStructureEqual("root\n" + ".Group:a\n" + "..Group:d\n" + "...ade\n" + "....Group:a\n" + ".....Group:d\n" + "......aed\n" + "..abc\n" + "...Group:a\n" + "....Group:d\n" + ".....abc_de\n" + ".Group:b\n" + "..Group:d\n" + "...bcd\n" + "....Group:b\n" + ".....bhg_yt\n" + "..Group:f\n" + "...bft\n" + "....ttt\n" + ".Group:d\n" + "..eed\n" + "...zzz\n" + ".xxx\n" + ".xxx\n" + "..Group:a\n" + "...aaa\n" + "....Group:b\n" + ".....bbb\n", PlatformTestUtil.createComparator(myPrintInfo)); }
Example #25
Source File: TestCaseLoader.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isBombed(final Class<?> testCaseClass) { final Bombed bombedAnnotation = testCaseClass.getAnnotation(Bombed.class); if (bombedAnnotation == null) return false; if (PlatformTestUtil.isRotten(bombedAnnotation)) { String message = "Disarm the stale bomb for '" + testCaseClass + "'"; System.err.println(message); // Assert.fail(message); } return !PlatformTestUtil.bombExplodes(bombedAnnotation); }
Example #26
Source File: TestCaseLoader.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isBombed(final Method method) { final Bombed bombedAnnotation = method.getAnnotation(Bombed.class); if (bombedAnnotation == null) return false; if (PlatformTestUtil.isRotten(bombedAnnotation)) { String message = "Disarm the stale bomb for '" + method + "' in class '" + method.getDeclaringClass() + "'"; System.err.println(message); //Assert.fail(message); } return !PlatformTestUtil.bombExplodes(bombedAnnotation); }
Example #27
Source File: FileEditorManagerTest.java From consulo with Apache License 2.0 | 4 votes |
@Override protected String getTestDataPath() { return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/platform/platform-tests/testData/fileEditorManager"; }
Example #28
Source File: HeavyFileEditorManagerTestCase.java From consulo with Apache License 2.0 | 4 votes |
protected VirtualFile getFile(String path) { return LocalFileSystem.getInstance().refreshAndFindFileByPath( PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/platform/platform-tests/testData/fileEditorManager" + path); }
Example #29
Source File: SmartTreeStructureTest.java From consulo with Apache License 2.0 | 4 votes |
private void assertStructureEqual(@NonNls String expected, @Nullable Comparator comparator) { SmartTreeStructure structure = new SmartTreeStructure(myFixture.getProject(), myModel); String actual = PlatformTestUtil.print(structure, structure.getRootElement(), 0, comparator, -1, '.', null).toString(); assertEquals(expected, actual); }
Example #30
Source File: TempDirectory.java From consulo with Apache License 2.0 | 4 votes |
@Override public Statement apply(Statement base, Description description) { myName = PlatformTestUtil.lowercaseFirstLetter(FileUtil.sanitizeFileName(description.getMethodName(), false), true); return super.apply(base, description); }