Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
268,000
void () { String a = "1"; String b = "2"; String c = "3"; String d = "4"; String e = "5"; String f = "6"; }
run
268,001
void () { int a = 2; int b = 3; int c = 4; int d = 12; int e = 212; int f = 31; int g = 33; }
run
268,002
void () { int a = 1; int b = 2; int c = 3; int d = 4; int e = 5; }
run
268,003
void (String[] args) { System.out.println("Hello\tworld!"); }
main
268,004
void (String[] args) {</selection> System.out.println("Hello\tworld!"); }
main
268,005
int (ThreadLocalRandom rnd) { return rnd.nextInt(minFileId, maxFileId + 1); }
generateFileId
268,006
int (ThreadLocalRandom rnd, int subsetSize) { return rnd.nextInt(maxFileId + 1 - subsetSize, maxFileId + 1); }
generateFileId
268,007
int (Context mainContext) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); return mainContext.generateFileId(rnd, mainContext.FILES_TO_ACCESS); }
_baseline_rnd_
268,008
int (UTF8Context ctx) { int[] offsets = ctx.offsets; ByteBuffer buffer = ctx.buffer; return randomOffsetOf(offsets); }
_baseline_randomOffset
268,009
String[] (int stringsCount) { String[] strings = new String[stringsCount]; for (int i = 0; i < stringsCount; i++) { strings[i] = "name." + "%s$22".formatted(i); } return strings; }
generateStrings
268,010
int (int[] offsets) { int index = ThreadLocalRandom.current().nextInt(offsets.length); return offsets[index]; }
randomOffsetOf
268,011
void () { cursor = 0; }
resetCursor
268,012
int () { cursor++; if (cursor >= RECORDS_COUNT) { cursor = 1; } return cursor; }
nextSequential
268,013
int () { return ThreadLocalRandom.current().nextInt(1, RECORDS_COUNT); }
nextRandom
268,014
void () { recordSizeInInts = recordSize / Integer.BYTES; array = new int[recordSizeInInts * RECORDS_COUNT]; }
setup
268,015
void () { recordSizeInInts = recordSize / Integer.BYTES; array = new AtomicIntegerArray(recordSizeInInts * RECORDS_COUNT); }
setup
268,016
void () { recordSizeInInts = recordSize / Integer.BYTES; buffer = ByteBuffer.allocate(recordSize * RECORDS_COUNT) .order(nativeOrder()); }
setup
268,017
void () { recordSizeInInts = recordSize / Integer.BYTES; buffer = ByteBuffer.allocateDirect(recordSize * RECORDS_COUNT) .order(nativeOrder()); }
setup
268,018
void () { buffer = null;//help GC unmap it faster }
close
268,019
int (final IterationState it, final ArrayState state) { final int recordSizeInInts = state.recordSizeInInts; final int[] array = state.array; int consumer = 1; final int offset = recordSizeInInts * it.nextSequential(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { consumer += array[offset +...
array_SequentialPlainRead
268,020
int (final IterationState it, final ArrayState state) { final int recordSizeInInts = state.recordSizeInInts; final int[] array = state.array; int consumer = 1; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { consumer += array[offset + rec...
array_RandomPlainRead
268,021
int (final IterationState it, final AtomicArrayState state) { final int recordSizeInInts = state.recordSizeInInts; final AtomicIntegerArray array = state.array; int consumer = 1; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { consumer +=...
array_RandomVolatileRead
268,022
int (final IterationState it, final ByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final ByteBuffer buffer = state.buffer; int consumer = 1; final int offset = recordSizeInInts * it.nextSequential(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { consumer += bu...
byteBuffer_SequentialPlainRead
268,023
int (final IterationState it, final ByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final ByteBuffer buffer = state.buffer; int consumer = 1; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { consumer += buffer...
byteBuffer_RandomPlainRead
268,024
int (final IterationState it, final DirectByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final ByteBuffer buffer = state.buffer; int consumer = 1; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { consumer += ...
byteBufferDirect_RandomPlainRead
268,025
int (final IterationState it, final ByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final int recordSizeBytes = state.recordSize; final ByteBuffer buffer = state.buffer; int consumer = 1; final int offset = recordSizeBytes * it.nextRandom(); for (int recordField = 0; recordField < recordSi...
byteBuffer_RandomVolatileRead_ViaVarHandle
268,026
void (final IterationState it, final ArrayState state) { final int recordSizeInInts = state.recordSizeInInts; final int[] array = state.array; final int offset = recordSizeInInts * it.nextSequential(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { array[offset + recordField] = recordField; ...
array_SequentialPlainWrite
268,027
void (final IterationState it, final ArrayState state) { final int recordSizeInInts = state.recordSizeInInts; final int[] array = state.array; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { array[offset + recordField] = recordField; } }
array_RandomPlainWrite
268,028
void (final IterationState it, final AtomicArrayState state) { final int recordSizeInInts = state.recordSizeInInts; final AtomicIntegerArray array = state.array; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { array.set(offset + recordFie...
array_RandomVolatileWrite
268,029
void (final IterationState it, final ByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final ByteBuffer buffer = state.buffer; final int offset = recordSizeInInts * it.nextSequential(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { buffer.putInt(offset + recordFi...
byteBuffer_SequentialPlainWrite
268,030
void (final IterationState it, final ByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final ByteBuffer buffer = state.buffer; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { buffer.putInt(offset + recordField,...
byteBuffer_RandomPlainWrite
268,031
void (final IterationState it, final DirectByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final ByteBuffer buffer = state.buffer; final int offset = recordSizeInInts * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; recordField++) { buffer.putInt(offset + record...
byteBufferDirect_RandomPlainWrite
268,032
void (final IterationState it, final ByteBufferState state) { final int recordSizeInInts = state.recordSizeInInts; final int recordSizeInBytes = state.recordSize; final ByteBuffer buffer = state.buffer; final int offset = recordSizeInBytes * it.nextRandom(); for (int recordField = 0; recordField < recordSizeInInts; rec...
byteBuffer_RandomVolatileWrite_ViaVarHandle
268,033
int () { ThreadLocalRandom rnd = ThreadLocalRandom.current(); int randomIndex = rnd.nextInt(foldersIds.size()); return foldersIds.getInt(randomIndex); }
tossFolderId
268,034
PersistentFSTreeAccessor (FSRecordsImpl vfs) { return new PersistentFSTreeAccessor(vfs.attributeAccessor(), vfs.recordAccessor(), vfs.connection()); }
createTreeAccessor
268,035
PersistentFSTreeAccessor (FSRecordsImpl vfs) { return new PersistentFSTreeRawAccessor(vfs.attributeAccessor(), vfs.recordAccessor(), vfs.connection()); }
createTreeAccessor
268,036
void () { this.fileIds = IntStream.range(1000, 1000 + SAME_NAME_FILES_COUNT) .toArray(); IntArrays.shuffle(this.fileIds, ThreadLocalRandom.current()); for (int fileId : this.fileIds) { invertedNameIndex.updateFileName(fileId, nameId, InvertedNameIndex.NULL_NAME_ID); } }
setup
268,037
void (final Context context) { final int[] fileIdsToRemove = context.fileIds; final int nameId = context.nameId; final InvertedNameIndex invertedNameIndex = context.invertedNameIndex; for (int fileId : fileIdsToRemove) { invertedNameIndex.updateFileName(fileId, InvertedNameIndex.NULL_NAME_ID, nameId); } }
removeManyFilesWithSameName
268,038
Int2IntOpenHashMap (int keysCount) { final Int2IntOpenHashMap keyValues = new Int2IntOpenHashMap(keysCount); final ThreadLocalRandom rnd = ThreadLocalRandom.current(); for (int i = 0; i < keysCount; i++) { final int key = rnd.nextInt(); final int value = rnd.nextInt(); keyValues.put(key, value); } return keyValues; }
generateKeyValues
268,039
Int2IntOpenHashMap (int keysCount) { final Int2IntOpenHashMap keyValues = new Int2IntOpenHashMap(keysCount); final ThreadLocalRandom rnd = ThreadLocalRandom.current(); for (int i = 0; i < keysCount; i++) { final int key = rnd.nextInt(); final int value = rnd.nextInt(); keyValues.put(key, value); } return keyValues; }
generateKeyValues
268,040
int (ThreadLocalRandom rnd) { return rnd.nextInt(minFileId, maxFileId + 1); }
generateFileId
268,041
int (Context mainContext) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); return mainContext.generateFileId(rnd); }
_baseline_rnd_
268,042
PersistentFSConnection (Path cachesDir, int version) { VFSInitializationResult initResult = PersistentFSConnector.connectWithoutVfsLog( cachesDir, version ); return initResult.connection; }
initVFS
268,043
File () { return vfsFolder; }
vfsFolder
268,044
FSRecordsImpl () { return vfs; }
vfs
268,045
VirtualFile (final @NotNull File file) { return Objects.requireNonNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file), file.getPath()); }
refreshAndFind
268,046
TimestampsImmutable (final ApplicationContext application, final Context context) { return FSRecords.readAttributeRawWithLock( context.fileId, PERSISTENCE, TimestampsImmutable::readTimestamps ); }
readIndexStamps_ViaRawByteBuffer
268,047
void () { }
lock
268,048
boolean () { return true; }
tryLock
268,049
void () { }
unlock
268,050
Condition () { throw new UnsupportedOperationException("Method is not implemented"); }
newCondition
268,051
void () { lockToAcquire = switch (LOCK_KIND) { case "dummyLock" -> DUMMY_LOCK; case "reentrantLock" -> reentrantLock; case "readWrite.readLock" -> readWriteLock.readLock(); case "readWrite.writeLock" -> readWriteLock.writeLock(); default -> throw new IllegalStateException("LOCK_KIND: " + LOCK_KIND + " is unrecognized")...
setup
268,052
void (LockContext context) { Blackhole.consumeCPU(TASK_SIZE_UNDER_LOCK); }
noLock_baseline
268,053
IntSLRUCache<String> (int prot, int prob) { return new IntSLRUCache<>(prot, prob); }
createCache
268,054
void () { IntSLRUCache<String> cache = createCache(1, 1); cache.cacheEntry(0, "0"); assert cache.getCachedEntry(0) != null; assert cache.getCachedEntry(1) == null; }
testCachedAfterAdd
268,055
void () { IntSLRUCache<String> cache = createCache(2, 2); cache.cacheEntry(0, "0"); cache.cacheEntry(1, "1"); cache.cacheEntry(2, "2"); assert cache.getCachedEntry(0) == null; assert cache.getCachedEntry(1) != null; assert cache.getCachedEntry(2) != null; }
testEvictInfrequent
268,056
void () { IntSLRUCache<String> cache = createCache(2, 2); cache.cacheEntry(0, "0"); cache.cacheEntry(1, "1"); assert cache.getCachedEntry(0) != null; cache.cacheEntry(2, "2"); cache.cacheEntry(3, "3"); assert cache.getCachedEntry(0) != null; assert cache.getCachedEntry(1) == null; assert cache.getCachedEntry(2) != null...
testFrequentlyAccessedShouldSurvive
268,057
void () { IntSLRUCache<String> cache = createCache(1, 1); cache.cacheEntry(0, "0"); assert cache.getCachedEntry(0) != null; // protected now cache.cacheEntry(1, "1"); cache.cacheEntry(2, "2"); assert cache.getCachedEntry(0) != null; // still protected assert cache.getCachedEntry(1) == null; assert cache.getCachedEntry(...
testDropFrequentlyAccessedInThePast
268,058
void () { IntSLRUCache<String> cache = createCache(1, 1); cache.cacheEntry(0, "0"); assert cache.getCachedEntry(0) != null; cache.cacheEntry(1, "1"); assert cache.getCachedEntry(1) != null; assert cache.getCachedEntry(0) != null; assert cache.getCachedEntry(1) != null; assert cache.getCachedEntry(0) != null; cache.cach...
testChangingWorkingSet
268,059
void () { Alarm alarm = new Alarm(getTestRootDisposable()); AtomicInteger executed = new AtomicInteger(); int N = 100000; Set<Thread> used = ConcurrentCollectionFactory.createConcurrentSet(); for (int i = 0; i < N; i++) { alarm.addRequest(() -> { executed.incrementAndGet(); used.add(Thread.currentThread()); }, 10); } w...
testOneAlarmDoesNotStartTooManyThreads
268,060
void () { Set<Thread> used = ConcurrentCollectionFactory.createConcurrentSet(); AtomicInteger executed = new AtomicInteger(); int N = 100000; List<Alarm> alarms = Stream.generate(() -> new Alarm(getTestRootDisposable())).limit(N).toList(); alarms.forEach(alarm -> alarm.addRequest(() -> { executed.incrementAndGet(); use...
testManyAlarmsDoNotStartTooManyThreads
268,061
void () { Alarm alarm = new Alarm(); StringBuilder sb = new StringBuilder(); Object modal = new Object(); LaterInvocator.enterModal(modal); try { ApplicationManager.getApplication().invokeLater(() -> TimeoutUtil.sleep(10), ModalityState.nonModal()); alarm.addRequest(() -> sb.append("1"), 0, ModalityState.nonModal()); a...
testOrderIsPreservedAfterModalitySwitching
268,062
void () { Alarm alarm = new Alarm(); StringBuilder sb = new StringBuilder(); alarm.addRequest(() -> sb.append("1"), 0, ModalityState.nonModal()); alarm.addRequest(() -> sb.append("2"), 5, ModalityState.nonModal()); assertEquals("", sb.toString()); alarm.drainRequestsInTest(); assertEquals("12", sb.toString()); }
testFlushImmediately
268,063
void () { Alarm alarm = new Alarm(getTestRootDisposable()); Throwable error = LoggedErrorProcessor.executeAndReturnLoggedError(() -> { alarm.addRequest(() -> { throw new RuntimeException("wtf"); }, 1); boolean caught = false; while (!alarm.isEmpty()) { try { UIUtil.dispatchAllInvocationEvents(); } catch (RuntimeExcepti...
testExceptionDuringAlarmExecutionMustManifestItselfInTests
268,064
void () { assertThrows(IllegalArgumentException.class, () -> new SingleAlarm(() -> {}, 1, null, Alarm.ThreadToUse.SWING_THREAD, null)); }
testSingleAlarmMustRefuseToInstantiateWithWrongModality
268,065
void () { List<String> src = IntStreamEx.range(0, 100).mapToObj(String::valueOf).toList(); AtomicBoolean processing = new AtomicBoolean(); parallelQuery(src).forEach(__ -> { assertTrue(processing.compareAndSet(false, true)); TimeoutUtil.sleep(1); processing.set(false); return true; }); }
testForEachIsThreadSafeByDefault
268,066
void () { int cores = Runtime.getRuntime().availableProcessors(); assertTrue(cores > 1); int eachSleep = 200; long start = System.currentTimeMillis(); parallelQuery(Arrays.asList("a", "b")).allowParallelProcessing().forEach(__ -> { TimeoutUtil.sleep(eachSleep); return true; }); long elapsed = System.currentTimeMillis()...
testForEachIsParallelWhenAllowed
268,067
AbstractQuery<String> (List<String> strings) { return new AbstractQuery<>() { @Override protected boolean processResults(@NotNull Processor<? super String> consumer) { JobLauncher.getInstance().invokeConcurrentlyUnderProgress(strings, null, consumer); return false; } }; }
parallelQuery
268,068
boolean (@NotNull Processor<? super String> consumer) { JobLauncher.getInstance().invokeConcurrentlyUnderProgress(strings, null, consumer); return false; }
processResults
268,069
void () { Vector vector = Vector.create(0, 1, 2, 3, 4); int size = vector.getSize(); assertEquals(5, size); for (int i = 0; i < size; i++) { assertEquals((double)i, vector.get(i)); } }
testCreate
268,070
void () { try { fail("Created " + Vector.create()); } catch (Exception ignored) { } }
testCreateEmpty
268,071
void () { try { fail("Created " + Vector.create((double[])null)); } catch (Exception ignored) { } }
testCreateNull
268,072
void () { // see http://ru.onlinemschool.com/math/library/vector/add_subtract/ assertEquals(Vector.create(5, 10), Vector.create(1, 2).plus(Vector.create(4, 8))); assertEquals(Vector.create(5, 10, 6), Vector.create(1, 2, 5).plus(Vector.create(4, 8, 1))); assertEquals(Vector.create(5, 10, 6, -11), Vector.create(1, 2, 5, ...
testPlus
268,073
void () { try { fail("Created " + Vector.create(1, 2).plus(Vector.create(1, 2, 3))); } catch (Exception ignored) { } }
testPlusWrong
268,074
void () { // see http://ru.onlinemschool.com/math/library/vector/add_subtract/ assertEquals(Vector.create(-3, -6), Vector.create(1, 2).minus(Vector.create(4, 8))); assertEquals(Vector.create(-3, -6, 4), Vector.create(1, 2, 5).minus(Vector.create(4, 8, 1))); assertEquals(Vector.create(-3, -6, 4, 0, 3), Vector.create(1, ...
testMinus
268,075
void () { try { fail("Created " + Vector.create(1, 2).minus(Vector.create(1, 2, 3))); } catch (Exception ignored) { } }
testMinusWrong
268,076
void () { // see http://ru.onlinemschool.com/math/library/vector/multiply3/ assertEquals(Vector.create(3, 6), Vector.create(1, 2).multiply(3)); assertEquals(Vector.create(-2, -4, 10), Vector.create(1, 2, -5).multiply(-2)); }
testMultiplyByValue
268,077
void () { Vector vector = Vector.create(1, 2, 3); assertEquals(vector, vector.multiply(Matrix.createIdentity(3))); Matrix matrix = Matrix.create(3, /*row:*/ 11, 21, /*row:*/ 12, 22, /*row:*/ 13, 23); Vector result = vector.multiply(matrix); assertEquals(Vector.create(74, 134), result); assertEquals(matrix.getColumns(),...
testMultiplyByMatrix
268,078
void () { assertEquals(Vector.create(4, 8).multiply(Vector.create(1, 2)), Vector.create(1, 2).multiply(Vector.create(4, 8))); // see http://ru.onlinemschool.com/math/library/vector/multiply/ assertEquals(20.0, Vector.create(1, 2).multiply(Vector.create(4, 8))); assertEquals(15.0, Vector.create(1, 2, -5).multiply(Vector...
testMultiplyByVector
268,079
void () { try { fail("Created " + Vector.create(1, 2).minus(Vector.create(1, 2, 3))); } catch (Exception ignored) { } }
testMultiplyByVectorWrong
268,080
void () { // see http://ru.onlinemschool.com/math/library/vector/length/ assertEquals(5.0, Vector.create(3, -4).length()); assertEquals(6.0, Vector.create(2, 4, 4).length()); }
testLength
268,081
String () { return PlatformTestUtil.getPlatformTestDataPath(); }
getTestDataPath
268,082
void () { PsiFile file = myFixture.configureByText(StdFileTypes.XML, "<hello></hello>"); Assert.assertFalse(PsiErrorElementUtil.hasErrors(getProject(), file.getVirtualFile())); }
testNoErrors
268,083
void () { PsiFile file = myFixture.configureByText(StdFileTypes.XML, "<hello></hello"); Assert.assertTrue(PsiErrorElementUtil.hasErrors(getProject(), file.getVirtualFile())); }
testErrors
268,084
TestTimeOut (long timeout, @NotNull TimeUnit unit) { return new TestTimeOut(System.currentTimeMillis() + unit.toMillis(timeout)); }
setTimeout
268,085
boolean () { return timedOut(null); }
timedOut
268,086
boolean (Object workProgress) { if (isTimedOut()) { System.err.println("Timed out. Stopped at "+workProgress); return true; } return false; }
timedOut
268,087
boolean () { return System.currentTimeMillis() > timeOutMs; }
isTimedOut
268,088
void () { assertThat(getChildren()).isEmpty(); }
testNoChildren
268,089
void () { MockComponent label1 = new MockComponent("1"); myPanel.add(label1); MockComponent label2 = new MockComponent("2"); myPanel.add(label2); assertThat(getChildren()).containsExactly(label1, label2); }
testOneLevel
268,090
void () { MockComponent label1 = new MockComponent("1"); MockComponent label2 = new MockComponent("2"); MockComponent label3 = new MockComponent("3"); MockComponent label4 = new MockComponent("4"); myPanel.add(label1); JPanel subPanel = new JPanel(); myPanel.add(subPanel); subPanel.add(label2); subPanel.add(label3); my...
testubTree
268,091
List<Component> () { return UIUtil.uiTraverser(myPanel).traverse().skip(1).toList(); }
getChildren
268,092
String () { return myName; }
toString
268,093
void () { Matrix matrix = Matrix.create(3, /*row:*/ 11, 21, /*row:*/ 12, 22, /*row:*/ 13, 23); int width = matrix.getColumns(); assertEquals(2, width); int height = matrix.getRows(); assertEquals(3, height); for (int w = 0; w < width; w++) { for (int h = 0; h < height; h++) { assertEquals((double)(10 * (w + 1) + (h + 1...
testCreate
268,094
void () { try { fail("Created " + Matrix.create(0)); } catch (Exception ignored) { } }
testCreateEmpty
268,095
void () { try { fail("Created " + Matrix.create(0, (double[])null)); } catch (Exception ignored) { } }
testCreateNull
268,096
void () { try { fail("Created " + Matrix.create(2, 0)); } catch (Exception ignored) { } }
testCreateZeroWidth
268,097
void () { try { fail("Created " + Matrix.create(0, 0)); } catch (Exception ignored) { } }
testCreateZeroHeight
268,098
void () { Matrix matrix = Matrix.createIdentity(3); int width = matrix.getColumns(); assertEquals(3, width); int height = matrix.getRows(); assertEquals(3, height); for (int w = 0; w < width; w++) { for (int h = 0; h < height; h++) { assertEquals((double)(w == h ? 1 : 0), matrix.get(w, h)); } } Vector vector0 = Vector....
testCreateIdentity
268,099
void () { try { fail("Created " + Matrix.createIdentity(-1)); } catch (Exception ignored) { } }
testCreateIdentityWrong