I am using JMH to test some features of my project. When I try to use it's @GroupThreads with AtomicInteger, I cannot reset the AtomicInteger, it just increases over time. I also tried with if else to check and reset AtomicInteger but cannot. Could you please give me some suggestion for my problem? Thank a lot.
class JMHSample_15_Asymmetric {
private var counter: AtomicInteger = _
@Setup
def up() {
counter = new AtomicInteger
}
@Benchmark
@Group("g")
@GroupThreads(3)
def inc: Int = {
counter.compareAndSet(10,-1)
counter.incrementAndGet
}
@Benchmark
@Group("g")
@GroupThreads(1)
def get: Int = {
println("Counter --> "+ counter.get)
counter.get
}
}