Search in sources :

Example 1 with TLongLongHashMap

use of gnu.trove.TLongLongHashMap in project intellij-community by JetBrains.

the class CpuUsageData method measureCpuUsage.

public static <E extends Throwable> CpuUsageData measureCpuUsage(ThrowableRunnable<E> runnable) throws E {
    FreeMemorySnapshot memStart = new FreeMemorySnapshot();
    TObjectLongHashMap<GarbageCollectorMXBean> gcTimes = new TObjectLongHashMap<>();
    for (GarbageCollectorMXBean bean : ourGcBeans) {
        gcTimes.put(bean, bean.getCollectionTime());
    }
    TLongLongHashMap threadTimes = new TLongLongHashMap();
    for (long id : ourThreadMXBean.getAllThreadIds()) {
        threadTimes.put(id, ourThreadMXBean.getThreadUserTime(id));
    }
    long compStart = ourCompilationMXBean.getTotalCompilationTime();
    long start = System.currentTimeMillis();
    runnable.run();
    long duration = System.currentTimeMillis() - start;
    long compTime = ourCompilationMXBean.getTotalCompilationTime() - compStart;
    FreeMemorySnapshot memEnd = new FreeMemorySnapshot();
    for (long id : ourThreadMXBean.getAllThreadIds()) {
        threadTimes.put(id, ourThreadMXBean.getThreadUserTime(id) - threadTimes.get(id));
    }
    for (GarbageCollectorMXBean bean : ourGcBeans) {
        gcTimes.put(bean, bean.getCollectionTime() - gcTimes.get(bean));
    }
    return new CpuUsageData(duration, gcTimes, threadTimes, compTime, memStart, memEnd);
}
Also used : TObjectLongHashMap(gnu.trove.TObjectLongHashMap) TLongLongHashMap(gnu.trove.TLongLongHashMap)

Aggregations

TLongLongHashMap (gnu.trove.TLongLongHashMap)1 TObjectLongHashMap (gnu.trove.TObjectLongHashMap)1