< prev index next >

test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantMapped.java

Print this page

 38 import sun.misc.Unsafe;
 39 
 40 import java.io.File;
 41 import java.io.IOException;
 42 import java.nio.ByteBuffer;
 43 import java.nio.ByteOrder;
 44 import java.nio.MappedByteBuffer;
 45 import java.nio.channels.FileChannel;
 46 import java.nio.file.Files;
 47 import java.nio.file.Path;
 48 import java.nio.file.StandardOpenOption;
 49 import java.util.concurrent.TimeUnit;
 50 
 51 import static java.lang.foreign.ValueLayout.*;
 52 
 53 @BenchmarkMode(Mode.AverageTime)
 54 @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 55 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 56 @State(org.openjdk.jmh.annotations.Scope.Thread)
 57 @OutputTimeUnit(TimeUnit.MILLISECONDS)
 58 @Fork(value = 3, jvmArgsAppend = "--enable-preview")
 59 public class LoopOverNonConstantMapped extends JavaLayouts {
 60 
 61     static final Unsafe unsafe = Utils.unsafe;
 62 
 63     static final int ELEM_SIZE = 1_000_000;
 64     static final int CARRIER_SIZE = (int)JAVA_INT.byteSize();
 65     static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE;
 66 
 67     static final Path tempPath;
 68 
 69     static {
 70         try {
 71             File file = File.createTempFile("buffer", "txt");
 72             file.deleteOnExit();
 73             tempPath = file.toPath();
 74             Files.write(file.toPath(), new byte[ALLOC_SIZE], StandardOpenOption.WRITE);
 75 
 76         } catch (IOException ex) {
 77             throw new ExceptionInInitializerError(ex);
 78         }

 38 import sun.misc.Unsafe;
 39 
 40 import java.io.File;
 41 import java.io.IOException;
 42 import java.nio.ByteBuffer;
 43 import java.nio.ByteOrder;
 44 import java.nio.MappedByteBuffer;
 45 import java.nio.channels.FileChannel;
 46 import java.nio.file.Files;
 47 import java.nio.file.Path;
 48 import java.nio.file.StandardOpenOption;
 49 import java.util.concurrent.TimeUnit;
 50 
 51 import static java.lang.foreign.ValueLayout.*;
 52 
 53 @BenchmarkMode(Mode.AverageTime)
 54 @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 55 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 56 @State(org.openjdk.jmh.annotations.Scope.Thread)
 57 @OutputTimeUnit(TimeUnit.MILLISECONDS)
 58 @Fork(3)
 59 public class LoopOverNonConstantMapped extends JavaLayouts {
 60 
 61     static final Unsafe unsafe = Utils.unsafe;
 62 
 63     static final int ELEM_SIZE = 1_000_000;
 64     static final int CARRIER_SIZE = (int)JAVA_INT.byteSize();
 65     static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE;
 66 
 67     static final Path tempPath;
 68 
 69     static {
 70         try {
 71             File file = File.createTempFile("buffer", "txt");
 72             file.deleteOnExit();
 73             tempPath = file.toPath();
 74             Files.write(file.toPath(), new byte[ALLOC_SIZE], StandardOpenOption.WRITE);
 75 
 76         } catch (IOException ex) {
 77             throw new ExceptionInInitializerError(ex);
 78         }
< prev index next >