Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
268,500 | void () { final List<Object> stock = new CopyOnWriteArrayList<>(); measure(stock); final List<Object> my = new LockFreeCopyOnWriteArrayList<>(); measure(my); measure(stock); measure(my); // warm up for (int i = 0; i < 5; i++) { long stockElapsed = measure(stock); long myElapsed = measure(my); LOG.debug("LockFree my: " ... | testLockFreeSingleThreadPerformance |
268,501 | long (List<Object> list) { long start = System.currentTimeMillis(); for (int n = 0; n < 10000000; n++) { list.add(this); list.remove(this); list.add(this); list.remove(0); } long finish = System.currentTimeMillis(); assertTrue(list.isEmpty()); return finish - start; } | measure |
268,502 | void () { LockFreeCopyOnWriteArrayList<Object> my = (LockFreeCopyOnWriteArrayList<Object>)ContainerUtil.createLockFreeCopyOnWriteList(); for (int i = 0; i < 2; i++) { Object[] array = my.getArray(); assertSame(ArrayUtilRt.EMPTY_OBJECT_ARRAY, array); assertReallyEmpty(my); my.add(this); my.remove(this); assertReallyEmpt... | testLockFreeCOWDoesNotCreateEmptyArrays |
268,503 | void () { List<Object> list = ContainerUtil.createLockFreeCopyOnWriteList(); int count = 15000; List<Integer> ints = IntStreamEx.range(0, count).boxed().toList(); PlatformTestUtil.startPerformanceTest("COWList add", 4500, () -> { for (int it = 0; it < 10; it++) { list.clear(); for (int i = 0; i < count; i++) { list.add... | testCOWListPerformanceAdd |
268,504 | void (List<?> my) { assertEquals(0, my.size()); Object[] objects = my.toArray(); assertSame(ArrayUtilRt.EMPTY_OBJECT_ARRAY, objects); Iterator<?> iterator = my.iterator(); assertSame(Collections.emptyIterator(), iterator); } | assertReallyEmpty |
268,505 | void () { List<String> list = ContainerUtil.createLockFreeCopyOnWriteList(Arrays.asList("a", "b")); list.add("a"); assertEquals(3, list.size()); list.remove("a"); assertEquals(2, list.size()); list.remove("a"); assertEquals(1, list.size()); } | testIdenticalItemsInLockFreeCOW |
268,506 | void () { List<String> seq = Arrays.asList("0", "1", "2", "3", "4"); LockFreeCopyOnWriteArrayList<String> my = (LockFreeCopyOnWriteArrayList<String>)ContainerUtil.createLockFreeCopyOnWriteList(seq); { Iterator<String> iterator = my.iterator(); try { iterator.remove(); fail("must not be able to remove before next() call... | testLockFreeCOWIteratorRemove |
268,507 | void () { String value = "stringValue"; List<String> expected = ContainerUtil.immutableList(value); List<String> actual = List.of(value); assertEquals(expected, actual); } | testImmutableListEquals |
268,508 | void () { List<Segment> target = new ArrayList<>(Arrays.asList( range(0, 0), range(2, 2), range(4, 4), range(6, 6) )); List<Segment> source = Arrays.asList( range(1, 1), range(2, 2), range(2, 3) ); target = mergeSegmentLists(target, source); assertEquals(Arrays.asList( range(0, 0), range(1, 1), range(2, 2), range(2, 3)... | testMergeSortedLists |
268,509 | Segment (int start, int end) { return new UnfairTextRange(start, end); } | range |
268,510 | List<Segment> (List<? extends Segment> list1, List<? extends Segment> list2) { return ContainerUtil.mergeSortedLists(list1, list2, Segment.BY_START_OFFSET_THEN_END_OFFSET, true); } | mergeSegmentLists |
268,511 | void () { List<Integer> list1 = Collections.singletonList(0); List<Integer> list2 = Collections.singletonList(4); List<Integer> m = ContainerUtil.mergeSortedLists(list1, list2, Comparator.naturalOrder(), true); assertEquals(Arrays.asList(0, 4), m); m = ContainerUtil.mergeSortedLists(list2, list1, Comparator.naturalOrde... | testMergeSortedArrays |
268,512 | void () { int[] a1 = {0, 4}; int[] a2 = {4}; int[] m = ArrayUtil.mergeSortedArrays(a1, a2, true); Assert.assertArrayEquals(new int[]{0, 4}, m); m = ArrayUtil.mergeSortedArrays(a2, a1, true); Assert.assertArrayEquals(new int[]{0, 4}, m); } | testMergeSortedArrays2 |
268,513 | void () { List<Integer> list = ContainerUtil.immutableList(0, 1, 2, 3, 4); List<Integer> subList = list.subList(1, 4); UsefulTestCase.assertOrderedEquals(subList, 1, 2, 3); List<Integer> subSubList = subList.subList(1, 2); UsefulTestCase.assertOrderedEquals(subSubList, 2); assertEquals(new ArrayList<>(subSubList), subS... | testImmutableListSubList |
268,514 | void () { List<Integer> list = ContainerUtil.flatMap(List.of(0, 1), i->List.of(i,i)); assertEquals(List.of(0,0,1,1), list); } | testFlatMap |
268,515 | void (int L, int N) { boolean[] indexMask = new boolean[L]; int[] indicesToSet = new Random().ints(L / 2, 0, L).peek(i->indexMask[i]=true).toArray(); long distinctIndexNumber = Arrays.stream(indicesToSet).distinct().count(); ExecutorService executor = create4ThreadsExecutor(); try { Set<Thread> threadUsed = ConcurrentC... | tortureParallelSetClear |
268,516 | ExecutorService () { // because TC usually has no more than 4 cores AtomicInteger cnt = new AtomicInteger(); return new ThreadPoolExecutor(4, 4, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), r -> new Thread(r, "ConcurrentBitSetTest.tortureParallelSetClear-"+cnt.getAndIncrement())); } | create4ThreadsExecutor |
268,517 | void (ExecutorService executor, Set<? super Thread> threadUsed, Semaphore threadReady, int L, IntConsumer index) { assert L % 4 == 0; threadUsed.clear(); threadReady.down();threadReady.down();threadReady.down();threadReady.down(); List<? extends Future<?>> futures = IntStream.range(0, 4).mapToObj(chunk -> executor.subm... | boundedParallelRun |
268,518 | ByteArraySequence[] (@NotNull ThreadLocalRandom rnd, int size) { return uniqueHashesStream(rnd, size) .toArray(ByteArraySequence[]::new); } | generateUniqueHashes |
268,519 | Stream<ByteArraySequence> (@NotNull ThreadLocalRandom rnd, int size) { return IntStream.iterate(0, i -> i + 1) .mapToObj(i -> randomHash(rnd)) .distinct() .limit(size); } | uniqueHashesStream |
268,520 | ByteArraySequence (final Random rnd) { final byte[] hash = new byte[ContentHashEnumerator.SIGNATURE_LENGTH]; for (int i = 0; i < hash.length; i++) { hash[i] = (byte)rnd.nextInt(Byte.MIN_VALUE, Byte.MAX_VALUE + 1); } return new ByteArraySequence(hash); } | randomHash |
268,521 | void () { assertTrue(myTrustManager.containsCertificate(AUTHORITY_CN)); } | testSetUp |
268,522 | String () { return PlatformTestUtil.getPlatformTestDataPath(); } | getTestDataPath |
268,523 | void () { final MyUpdate first = new MyUpdate("first"); final MyUpdate second = new MyUpdate("second"); final MyQueue queue = new MyQueue(); queue.queue(first); queue.queue(second); assertFalse(first.isExecuted()); assertFalse(second.isExecuted()); queue.showNotify(); waitForExecution(queue); assertAfterProcessing(firs... | testOnShowNotify |
268,524 | void () { final boolean[] attemps = new boolean[3]; final MyQueue queue = new MyQueue(); final MyUpdate first = new MyUpdate("addedFirstButRunLast") { // default priority is 999 @Override public void run() { super.run(); attemps[0] = true; assertTrue(attemps[1]); assertTrue(attemps[2]); } }; final MyUpdate second = new... | testPriority |
268,525 | void () { super.run(); attemps[0] = true; assertTrue(attemps[1]); assertTrue(attemps[2]); } | run |
268,526 | void () { super.run(); assertFalse(attemps[0]); attemps[1] = true; assertFalse(attemps[2]); } | run |
268,527 | void () { super.run(); assertFalse(attemps[0]); assertTrue(attemps[1]); attemps[2] = true; } | run |
268,528 | void () { final boolean[] expired = new boolean[1]; final MyUpdate first = new MyUpdate("first") { @Override public boolean isExpired() { return expired[0]; } }; final MyUpdate second = new MyUpdate("second"); final MyQueue queue = new MyQueue(); queue.queue(first); queue.queue(second); assertFalse(first.isExecuted());... | testDoNoExecuteExpired |
268,529 | boolean () { return expired[0]; } | isExpired |
268,530 | void () { final MyUpdate twin1 = new MyUpdate("twin"); final MyUpdate twin2 = new MyUpdate("twin"); final MyQueue queue = new MyQueue(); queue.queue(twin1); queue.queue(twin2); assertFalse(twin1.isExecuted()); assertFalse(twin2.isExecuted()); queue.showNotify(); waitForExecution(queue); assertAfterProcessing(twin1, fal... | testOnShowNotifyMerging |
268,531 | void () { final MyQueue queue = new MyQueue(); queue.showNotify(); final MyUpdate first = new MyUpdate("first"); final MyUpdate second = new MyUpdate("second"); queue.queue(first); queue.queue(second); waitForExecution(queue); assertAfterProcessing(first, true, true); assertAfterProcessing(second, true, true); } | testExecuteWhenActive |
268,532 | void () { final MyQueue queue = new MyQueue(); queue.showNotify(); final MyUpdate twin1 = new MyUpdate("twin"); final MyUpdate twin2 = new MyUpdate("twin"); queue.queue(twin1); queue.queue(twin2); waitForExecution(queue); assertAfterProcessing(twin1, false, true); assertAfterProcessing(twin2, true, true); } | testMergeWhenActive |
268,533 | void () { executeEatingTest(false); } | testEatByQueue |
268,534 | void () { executeEatingTest(true); } | testEatUpdatesInQueue |
268,535 | void (boolean foodFirst) { final MyQueue queue = new MyQueue(); queue.showNotify(); final MyUpdate food = new MyUpdate("food"); MyUpdate hungry = new MyUpdate("hungry") { @Override public boolean canEat(@NotNull Update update) { return update == food; } }; if (foodFirst) { queue.queue(food); queue.queue(hungry); } else... | executeEatingTest |
268,536 | boolean (@NotNull Update update) { return update == food; } | canEat |
268,537 | void () { final MyQueue queue = new MyQueue(); queue.showNotify(); queue.queue(new MyUpdate("update") { @Override public boolean isExpired() { queue.flush(); return false; } }); waitForExecution(queue); } | testConcurrentFlushing |
268,538 | boolean () { queue.flush(); return false; } | isExpired |
268,539 | void () { final MyQueue queue = new MyQueue(); queue.showNotify(); queue.queue(new MyUpdate("update") { @Override public boolean isExpired() { queue.queue(new MyUpdate("update again")); return false; } }); waitForExecution(queue); } | testConcurrentQueueing |
268,540 | boolean () { queue.queue(new MyUpdate("update again")); return false; } | isExpired |
268,541 | void (MyUpdate update, boolean shouldBeExecuted, boolean shouldBeProcessed) { assertEquals(shouldBeExecuted, update.isExecuted()); assertEquals(shouldBeProcessed, update.wasProcessed()); } | assertAfterProcessing |
268,542 | void () { myExecuted = true; } | run |
268,543 | boolean () { return myExecuted; } | isExecuted |
268,544 | void () { } | run |
268,545 | void () { super.run(); } | onTimer |
268,546 | void (final Update @NotNull [] update) { super.execute(update); myExecuted = true; } | execute |
268,547 | boolean () { return true; } | isModalityStateCorrect |
268,548 | void (final MyQueue queue) { queue.onTimer(); new WaitFor(5000) { @Override protected boolean condition() { return queue.wasExecuted(); } }.assertCompleted(); } | waitForExecution |
268,549 | boolean () { return queue.wasExecuted(); } | condition |
268,550 | void () { final MyQueue queue = new MyQueue(); final AtomicInteger count = new AtomicInteger(); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { queue.queue(new Update("foo" + j) { @Override public void run() { count.incrementAndGet(); } }); } } queue.showNotify(); waitForExecution(queue); assertEquals(1... | testReallyMergeEqualIdentityEqualPriority |
268,551 | void () { count.incrementAndGet(); } | run |
268,552 | void () { count.incrementAndGet(); } | run |
268,553 | void () { final MyQueue queue = new MyQueue(); StringBuilder expected = new StringBuilder(); final StringBuilder actual = new StringBuilder(); for (int i = 0; i < 20; i++) { expected.append(i); final int finalI = i; queue.queue(new Update(new Object()) { @Override public void run() { actual.append(finalI); } }); } queu... | testSamePriorityQueriesAreExecutedInAdditionOrder |
268,554 | void () { actual.append(finalI); } | run |
268,555 | void () { startedExecuting1.countDown(); try { canContinue.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } } | run |
268,556 | void () { startedExecuting2.countDown(); } | run |
268,557 | void () { MergingUpdateQueue queue = new MergingUpdateQueue(getTestName(false), 1000_000, true, null, getTestRootDisposable(), null, Alarm.ThreadToUse.POOLED_THREAD); Update update = new Update(this) { @Override public void run() { } }; queue.queue(update); assertFalse(update.isRejected()); Disposer.dispose(queue); ass... | testMustRejectOnDispose |
268,558 | void () { } | run |
268,559 | void () { DefaultMutableTreeNode root = new DefaultMutableTreeNode(); DefaultTreeModel model = new DefaultTreeModel(root); DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("1"); model.insertNodeInto(child1, root, 0); model.insertNodeInto(new DefaultMutableTreeNode("2"), root, 1); assertSame(child1, TreeUtil.f... | testFindNodeWithObject |
268,560 | void () { waitForTestOnEDT(TreeUtilTest::implRemoveSelected); } | testRemoveSelected |
268,561 | void () { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultTreeModel model = new DefaultTreeModel(root); DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("1"); model.insertNodeInto(child1, root, 0); DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("2"); model.insertNodeInto(c... | implRemoveSelected |
268,562 | void () { waitForTestOnEDT(TreeUtilTest::implMultiLevelRemove); } | testMultiLevelRemove |
268,563 | void () { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultTreeModel model = new DefaultTreeModel(root) { @Override public void removeNodeFromParent(MutableTreeNode mutableTreeNode) { super.removeNodeFromParent((MutableTreeNode) mutableTreeNode.getParent()); } }; DefaultMutableTreeNode node1 = n... | implMultiLevelRemove |
268,564 | void (MutableTreeNode mutableTreeNode) { super.removeNodeFromParent((MutableTreeNode) mutableTreeNode.getParent()); } | removeNodeFromParent |
268,565 | void () { waitForTestOnEDT(TreeUtilTest::implRemoveLast); } | testRemoveLast |
268,566 | void () { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultTreeModel model = new DefaultTreeModel(root); model.insertNodeInto(new DefaultMutableTreeNode("1"), root, 0); DefaultMutableTreeNode middle = new DefaultMutableTreeNode("2"); model.insertNodeInto(middle, root, 1); DefaultMutableTreeNode ... | implRemoveLast |
268,567 | void () { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("2"); root.add(node2); DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("1"); root.add(node1); DefaultMutableTreeNode node1_2 = new DefaultMutableTreeNode("1_2"); node1.add(node... | testSorting |
268,568 | void () { DefaultMutableTreeNode root = new DefaultMutableTreeNode("0"); DefaultMutableTreeNode node = new DefaultMutableTreeNode("00"); root.add(node); node.add(new DefaultMutableTreeNode("000")); node.add(new DefaultMutableTreeNode("001")); root.add(new DefaultMutableTreeNode("01")); final ArrayList order = new Array... | testTraverseDepth |
268,569 | void (@NotNull Runnable test) { if (EventQueue.isDispatchThread()) { test.run(); } else { try { EventQueue.invokeAndWait(test); } catch (InterruptedException exception) { throw new AssertionError(exception); } catch (InvocationTargetException exception) { Throwable target = exception.getTargetException(); ExceptionUtil... | waitForTestOnEDT |
268,570 | String () { return "LogInfo{" + "runnable=" + runnable + ", currentThread=" + currentThread + '}'; } | toString |
268,571 | void () { checkCriticalMethodsThrow(service); } | testMustNotBeAbleToShutdown |
268,572 | void () { ExecutorService service = AppExecutorUtil.getAppExecutorService(); checkCriticalMethodsThrow(service); } | testMustNotBeAbleToShutdownGlobalPool |
268,573 | void (ExecutorService service) { UsefulTestCase.assertThrows(IncorrectOperationException.class, "You must not call this method on the global app pool", () -> service.shutdown()); UsefulTestCase.assertThrows(IncorrectOperationException.class, "You must not call this method on the global app pool", () -> service.shutdown... | checkCriticalMethodsThrow |
268,574 | void () { checkExceptionIsReported( action -> service.scheduleWithFixedDelay(action, 1, 1, TimeUnit.MILLISECONDS) ); checkExceptionIsReported( action -> service.schedule(action, 1, TimeUnit.MILLISECONDS) ); } | testExceptionsFromScheduledTasksAreReported |
268,575 | void (Function<? super Runnable, ? extends ScheduledFuture<?>> runner) { Runnable fail = () -> { throw new RuntimeException("failed"); }; Throwable error = LoggedErrorProcessor.executeAndReturnLoggedError(() -> { ScheduledFuture<?> future = runner.apply(fail); waitFor(future::isDone); }); assertEquals("failed", error.g... | checkExceptionIsReported |
268,576 | void () { service.setBackendPoolCorePoolSize(1); ((ThreadPoolExecutor)service.backendExecutorService).prestartCoreThread(); assertEquals(1, service.getBackendPoolExecutorSize()); service.setNewThreadListener((thread, runnable) -> { Runnable firstTask = ReflectionUtil.getField(runnable.getClass(), runnable, Runnable.cla... | testDelayedTasksReusePooledThreadIfExecuteAtDifferentTimes |
268,577 | void () { f1Start.set(System.currentTimeMillis()); if (!log.isEmpty()) agentOverloaded.set(true); log.add(new LogInfo(1)); } | run |
268,578 | String () { return "f1"; } | toString |
268,579 | void () { f2Start.set(System.currentTimeMillis()); if (!f1.isDone()) agentOverloaded.set(true); log.add(new LogInfo(2)); } | run |
268,580 | String () { return "f2"; } | toString |
268,581 | void () { f3Start.set(System.currentTimeMillis()); if (!f1.isDone()) agentOverloaded.set(true); if (!f2.isDone()) agentOverloaded.set(true); log.add(new LogInfo(3)); } | run |
268,582 | String () { return "f3"; } | toString |
268,583 | void () { BlockingSet<String> lock = new BlockingSet<>(); lock.put("eins"); lock.put("zwei"); lock.remove("zwei"); lock.put("polizei"); lock.remove("polizei"); lock.remove("eins"); } | testSingleThreadLock |
268,584 | void () { BlockingSet<String> lock = new BlockingSet<>(); lock.put("eins"); lock.put("zwei"); lock.remove("eins"); lock.remove("polizei"); } | testReleaseNotAcquired |
268,585 | BoundedScheduledExecutorService (@NotNull ExecutorService backendExecutor, int maxTasks) { return new BoundedScheduledExecutorService("Running "+getName(), backendExecutor, maxTasks); } | createBoundedScheduledExecutor |
268,586 | void (ExecutorService executor) { if (executor instanceof ScheduledExecutorService s) { UsefulTestCase.assertThrows(RejectedExecutionException.class, () -> s.schedule(EmptyRunnable.getInstance(), 10, TimeUnit.SECONDS)); UsefulTestCase.assertThrows(RejectedExecutionException.class, () -> s.schedule(()->null, 10, TimeUni... | checkEveryPossibleSubmitThrows |
268,587 | void () { boolean isShutdown = executor.isShutdown(); assertTrue(shutdownCalled.get() || !isShutdown); } | run |
268,588 | String () { return getName()+": executor N"+count; } | toString |
268,589 | void () { TestTimeOut t = TestTimeOut.setTimeout(20, TimeUnit.SECONDS); while (!t.isTimedOut()) { BoundedScheduledExecutorService executor = createBoundedScheduledExecutor(AppExecutorUtil.getAppExecutorService(), 1); AtomicBoolean shutdownCalled = new AtomicBoolean(); Future<?> future1 = executor.scheduleWithFixedDelay... | testShutdownNowMustTerminateImmediately |
268,590 | void () { ExecutorService executor = createBoundedScheduledExecutor(AppExecutorUtil.getAppExecutorService(), 1); executor.shutdown(); assertTrue(executor.isShutdown()); executor.shutdown(); assertTrue(executor.isShutdown()); } | testShutdownMustBeIdempotentByExecutorServiceContract |
268,591 | void () { WaitFor waitFor = new WaitFor() { @Override public boolean condition() { return System.currentTimeMillis() > myStarted + 2000; } }; assertTrue("Condition isn't met", System.currentTimeMillis() > myStarted + 2000); assertTrue(waitFor.isConditionRealized()); assertFalse(waitFor.isInterrupted()); } | testWaitFor |
268,592 | boolean () { return System.currentTimeMillis() > myStarted + 2000; } | condition |
268,593 | void () { waitFor[0] = new WaitFor() { @Override protected boolean condition() { interrupt(); return false; } }; } | run |
268,594 | boolean () { interrupt(); return false; } | condition |
268,595 | boolean () { return System.currentTimeMillis() > myStarted + 2000; } | condition |
268,596 | boolean () { return System.currentTimeMillis() - myStarted > 2000; } | condition |
268,597 | boolean () { return waitFor.isConditionRealized(); } | condition |
268,598 | Set<Action> (@NotNull String category, @NotNull String message, String @NotNull [] details, @Nullable Throwable t) { if (t != null) { loggedError.compareAndSet(null, t); } return EnumSet.allOf(Action.class);//Action.ALL; } | processError |
268,599 | String () { return "A"+getName(); } | getPoolName |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.