Search in sources :

Example 1 with MyAtomicIntArray

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();
    }
}
Also used : MyAtomicIntArray(cn.myperf4j.base.util.concurrent.MyAtomicIntArray)

Example 2 with MyAtomicIntArray

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;
}
Also used : MyAtomicIntArray(cn.myperf4j.base.util.concurrent.MyAtomicIntArray)

Example 3 with MyAtomicIntArray

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);
}
Also used : MyAtomicIntArray(cn.myperf4j.base.util.concurrent.MyAtomicIntArray)

Example 4 with MyAtomicIntArray

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);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) MyAtomicIntArray(cn.myperf4j.base.util.concurrent.MyAtomicIntArray) Setup(org.openjdk.jmh.annotations.Setup)

Example 5 with MyAtomicIntArray

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();
}
Also used : MyAtomicIntArray(cn.myperf4j.base.util.concurrent.MyAtomicIntArray) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

MyAtomicIntArray (cn.myperf4j.base.util.concurrent.MyAtomicIntArray)5 AtomicIntegerArray (java.util.concurrent.atomic.AtomicIntegerArray)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 Setup (org.openjdk.jmh.annotations.Setup)1