use of gnu.trove.TLongArrayList in project intellij-community by JetBrains.
the class CachedValueBase method computeData.
private Data<T> computeData(@Nullable CachedValueProvider.Result<T> result) {
T value = result == null ? null : result.getValue();
Object[] dependencies = getDependencies(result);
if (dependencies == null) {
return new Data<>(value, null, null);
}
TLongArrayList timeStamps = new TLongArrayList(dependencies.length);
List<Object> deps = new ArrayList<>(dependencies.length);
collectDependencies(timeStamps, deps, dependencies);
return new Data<>(value, ArrayUtil.toObjectArray(deps), timeStamps.toNativeArray());
}
use of gnu.trove.TLongArrayList in project intellij-community by JetBrains.
the class ProgressIndicatorTest method testCheckCanceledGranularity.
public void testCheckCanceledGranularity() throws InterruptedException {
prevTime = now = 0;
final long warmupEnd = System.currentTimeMillis() + 1000;
final TLongArrayList times = new TLongArrayList();
final long end = warmupEnd + 1000;
ApplicationManagerEx.getApplicationEx().runProcessWithProgressSynchronously(() -> {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, getTestRootDisposable());
ProgressIndicatorEx indicator = (ProgressIndicatorEx) ProgressIndicatorProvider.getGlobalProgressIndicator();
prevTime = System.currentTimeMillis();
assert indicator != null;
indicator.addStateDelegate(new ProgressIndicatorStub() {
@Override
public void checkCanceled() throws ProcessCanceledException {
now = System.currentTimeMillis();
if (now > warmupEnd) {
int delta = (int) (now - prevTime);
times.add(delta);
}
prevTime = now;
}
});
while (System.currentTimeMillis() < end) {
ProgressManager.checkCanceled();
}
alarm.cancelAllRequests();
}, "", false, getProject(), null, "");
long averageDelay = ArrayUtil.averageAmongMedians(times.toNativeArray(), 5);
System.out.println("averageDelay = " + averageDelay);
assertTrue(averageDelay < CoreProgressManager.CHECK_CANCELED_DELAY_MILLIS * 3);
}
use of gnu.trove.TLongArrayList in project intellij-community by JetBrains.
the class JsonReaders method readLongArray.
public static long[] readLongArray(JsonReaderEx reader) {
checkIsNull(reader, null);
reader.beginArray();
if (!reader.hasNext()) {
reader.endArray();
return ArrayUtilRt.EMPTY_LONG_ARRAY;
}
TLongArrayList result = new TLongArrayList();
do {
result.add(reader.nextLong());
} while (reader.hasNext());
reader.endArray();
return result.toNativeArray();
}
use of gnu.trove.TLongArrayList in project intellij-community by JetBrains.
the class FileNameCacheMicroBenchmark method measureAverageTime.
private static void measureAverageTime(int[] ids, int threadCount, TestIteration iteration) throws InterruptedException, ExecutionException {
System.out.println("Running " + threadCount + " threads, using " + iteration);
TLongArrayList times = new TLongArrayList();
for (int i = 0; i < 10; i++) {
long time = runThreads(ids, threadCount, 2000000, /*0*/
iteration);
System.out.println(time);
times.add(time);
}
times.sort();
long median = times.get(times.size() / 2);
System.out.println("Median for " + threadCount + " threads: " + median + "ms");
System.out.println();
}
Aggregations