1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.openjdk.bench.valhalla.array.util; 24 25 import org.openjdk.bench.valhalla.util.SizeBase; 26 import org.openjdk.jmh.annotations.Setup; 27 28 public class PrimitiveStates extends SizeBase { 29 30 public static abstract class ByteState extends SizeState { 31 public byte[] arr; 32 void fill() { 33 for (int i = 0; i < arr.length; i++) { 34 arr[i] = (byte) i; 35 } 36 } 37 } 38 39 public static abstract class IntState extends SizeState { 40 public int[] arr; 41 void fill() { 42 for (int i = 0; i < arr.length; i++) { 43 arr[i] = i; 44 } 45 } 46 } 47 48 public static abstract class LongState extends SizeState { 49 public long[] arr; 50 void fill() { 51 for (int i = 0; i < arr.length; i++) { 52 arr[i] = i; 53 } 54 } 55 } 56 57 public static class Primitive32int extends IntState { 58 @Setup 59 public void setup() { 60 arr = new int[size]; 61 fill(); 62 } 63 } 64 65 public static class Primitive64byte extends ByteState { 66 @Setup 67 public void setup() { 68 arr = new byte[size * 8]; 69 fill(); 70 } 71 } 72 73 public static class Primitive64int extends IntState { 74 @Setup 75 public void setup() { 76 arr = new int[size * 2]; 77 fill(); 78 } 79 } 80 81 public static class Primitive64long extends LongState { 82 @Setup 83 public void setup() { 84 arr = new long[size]; 85 fill(); 86 } 87 } 88 89 public static class Primitive128int extends IntState { 90 @Setup 91 public void setup() { 92 arr = new int[size * 4]; 93 fill(); 94 } 95 } 96 97 98 }