use of cn.myperf4j.base.util.concurrent.MyAtomicIntArray in project MyPerf4J by ThinkpadNC5.
the class RoughRecorder method recordTime.
@Override
public void recordTime(final long startNanoTime, final long endNanoTime) {
if (startNanoTime > endNanoTime) {
return;
}
int oldValue;
final int elapsedTime = (int) ((endNanoTime - startNanoTime) / 1000000);
final MyAtomicIntArray timingArr = this.timingArr;
if (elapsedTime < timingArr.length() - 1) {
oldValue = timingArr.getAndIncrement(elapsedTime);
} else {
oldValue = timingArr.getAndIncrement(timingArr.length() - 1);
}
if (oldValue <= 0) {
diffCount.incrementAndGet();
}
}
use of cn.myperf4j.base.util.concurrent.MyAtomicIntArray in project MyPerf4J by ThinkpadNC5.
the class RoughRecorder method fillSortedRecords.
@Override
public long fillSortedRecords(final IntBuf intBuf) {
long totalCount = 0L;
final MyAtomicIntArray timingArr = this.timingArr;
for (int i = 0; i < timingArr.length(); ++i) {
final int count = timingArr.get(i);
if (count > 0) {
intBuf.write(i, count);
totalCount += count;
}
}
return totalCount;
}
use of cn.myperf4j.base.util.concurrent.MyAtomicIntArray in project MyPerf4J by ThinkpadNC5.
the class AccurateRecorder method fillSortedRecords.
@Override
public long fillSortedRecords(IntBuf intBuf) {
long totalCount = 0L;
final MyAtomicIntArray timingArr = this.timingArr;
for (int i = 0; i < timingArr.length(); ++i) {
final int count = timingArr.get(i);
if (count > 0) {
intBuf.write(i, count);
totalCount += count;
}
}
return totalCount + fillMapRecord(intBuf);
}
use of cn.myperf4j.base.util.concurrent.MyAtomicIntArray in project MyPerf4J by ThinkpadNC5.
the class AtomicIntArrayBench method setup.
@Setup
public void setup() {
jdkArray = new AtomicIntegerArray(1024);
myArray = new MyAtomicIntArray(1024);
}
use of cn.myperf4j.base.util.concurrent.MyAtomicIntArray in project MyPerf4J by ThinkpadNC5.
the class AtomicIntArrayBench method myArrayResetBench.
@Benchmark
public int myArrayResetBench() {
final MyAtomicIntArray myArray = this.myArray;
myArray.reset();
return myArray.length();
}
Aggregations