45 lines
895 B
Java
Raw Normal View History

2016-09-28 12:54:00 -06:00
// validating/jmh/JMH2.java
2020-10-07 13:35:40 -06:00
// (c)2020 MindView LLC: see Copyright.txt
2016-09-23 13:23:35 -06:00
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
package validating.jmh;
import java.util.*;
import org.openjdk.jmh.annotations.*;
2016-09-28 12:54:00 -06:00
import java.util.concurrent.TimeUnit;
2016-09-23 13:23:35 -06:00
@State(Scope.Thread)
2016-09-28 12:54:00 -06:00
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5)
@Measurement(iterations = 5)
@Fork(1)
public class JMH2 {
2016-09-23 13:23:35 -06:00
private long[] la;
2016-09-28 12:54:00 -06:00
@Param({
"1",
"10",
"100",
"1000",
"10000",
"100000",
"1000000",
"10000000",
"100000000",
"250000000"
})
int size;
2016-09-23 13:23:35 -06:00
@Setup
public void setup() {
2016-09-28 12:54:00 -06:00
la = new long[size];
2016-09-23 13:23:35 -06:00
}
@Benchmark
public void setAll() {
Arrays.setAll(la, n -> n);
}
@Benchmark
public void parallelSetAll() {
Arrays.parallelSetAll(la, n -> n);
}
}