// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;


import static com.yahoo.memory4.UnsafeUtil.unsafe;
import static java.lang.Math.pow;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.LongBuffer;
import com.yahoo.memory.AllocMemory;
import com.yahoo.memory.NativeMemory;
import com.yahoo.sketches.Util;
  //Must do write trial first
  private static final long trial_HeapArrayByIndex(final long[] array, final int arrLongs,
      final boolean read) {
    final long checkSum = (arrLongs * (arrLongs - 1L)) / 2L;
    final long startTime_nS, stopTime_nS;
    if (read) {
      //Timing interval for a single trial
      long trialSum = 0;
      startTime_nS = System.nanoTime();
      for (int i = 0; i < arrLongs; i++) { trialSum += array[i]; }
      stopTime_nS = System.nanoTime();
      if (trialSum != checkSum) {
        throw new IllegalStateException("Bad checksum: " + trialSum + " != " + checkSum);
      }
    } else { //write
      startTime_nS = System.nanoTime();
      for (int i = 0; i < arrLongs; i++) { array[i] = i; }
      stopTime_nS = System.nanoTime();
    }
    return stopTime_nS - startTime_nS;
  }

  /*************************************/
  //  UNSAFE DIRECT
  /*************************************/

  private void testNativeArrayByUnsafe() {
    Point p = new Point(ppo_, minGI_ - 1, 1 << lgMinLongs_, 1 << lgMaxTrials_); //just below start
    Point.printHeader();
    while ((p = getNextPoint(p)) != null) { //an array size point
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;


// Path: src/test/java/com/yahoo/memory4/MemoryPerformance.java
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import static java.lang.Math.pow;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.LongBuffer;
import com.yahoo.memory.AllocMemory;
import com.yahoo.memory.NativeMemory;
import com.yahoo.sketches.Util;

  //Must do write trial first
  private static final long trial_HeapArrayByIndex(final long[] array, final int arrLongs,
      final boolean read) {
    final long checkSum = (arrLongs * (arrLongs - 1L)) / 2L;
    final long startTime_nS, stopTime_nS;
    if (read) {
      //Timing interval for a single trial
      long trialSum = 0;
      startTime_nS = System.nanoTime();
      for (int i = 0; i < arrLongs; i++) { trialSum += array[i]; }
      stopTime_nS = System.nanoTime();
      if (trialSum != checkSum) {
        throw new IllegalStateException("Bad checksum: " + trialSum + " != " + checkSum);
      }
    } else { //write
      startTime_nS = System.nanoTime();
      for (int i = 0; i < arrLongs; i++) { array[i] = i; }
      stopTime_nS = System.nanoTime();
    }
    return stopTime_nS - startTime_nS;
  }

  /*************************************/
  //  UNSAFE DIRECT
  /*************************************/

  private void testNativeArrayByUnsafe() {
    Point p = new Point(ppo_, minGI_ - 1, 1 << lgMinLongs_, 1 << lgMaxTrials_); //just below start
    Point.printHeader();
    while ((p = getNextPoint(p)) != null) { //an array size point
      final long address = unsafe.allocateMemory(p.arrLongs << 3);