// Path: unsafe-tests/src/main/java/net/bramp/unsafe/examples/LongPoint.java
// public class LongPoint implements Comparable<LongPoint> {
//   public long x;
//   public long y;
// 
//   public LongPoint(long x, long y) {
//     this.x = x;
//     this.y = y;
//   }
// 
//   public String toString() {
//     return "Point(" + x + "," + y + ")";
//   }
// 
//   @Override public boolean equals(Object obj) {
//     if (this == obj) {
//       return true;
//     }
//     if (obj == null || getClass() != obj.getClass()) {
//       return false;
//     }
//     LongPoint longPoint = (LongPoint) obj;
//     return Objects.equal(x, longPoint.x) && Objects.equal(y, longPoint.y);
//   }
// 
//   @Override public int hashCode() {
//     return Objects.hashCode(x, y);
//   }
// 
//   public int compareTo(LongPoint obj) {
//     return ComparisonChain.start().compare(x, obj.x).compare(y, obj.y).result();
//   }
// }
// 
// Path: unsafe-tests/src/main/java/net/bramp/unsafe/examples/Person.java
// public class Person {
// 
//   final String name;
//   final long birthday; // Timestamp (as returned by currentTimeMillis)
//   final char gender;
// 
//   public Person(String name, long birthday, char gender) {
//     this.name = name;
//     this.birthday = birthday;
//     this.gender = gender;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public long getBirthday() {
//     return birthday;
//   }
// 
//   public char getGender() {
//     return gender;
//   }
// 
//   /**
//    * Note: Not accurate, but only used as an example.
//    *
//    * @return the age of the person in years.
//    */
//   public int getAge() {
//     return (int) ((System.currentTimeMillis() - birthday) / 1000 / 60 / 60 / 24 / 365);
//   }
// 
//   public String toString() {
//     return "Person(" + getName() + ", " + new Date(getBirthday()) + ", " + getGender() + ")";
//   }
// }


import net.bramp.unsafe.examples.LongPoint;
import net.bramp.unsafe.examples.Person;
import com.google.common.base.Stopwatch;
import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.TimeUnit;
    System.out
        .printf("Person len:%d header:%d\n", UnsafeHelper.sizeOf(p), UnsafeHelper.headerSize(p));
    UnsafeHelper.hexDump(System.out, p);
  }

  /**
   * <pre>
   * _________________________________________________________________
   * | Test                 | Trial| Time (s)| Extra                  |
   * |================================================================|
   * | Create               | 0    | 19.281  |                        |
   * | Safelist Sum         | 0    | 0.208   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 0    | 0.448   | -1254641639, 1253696635|
   * | Safelist Sum         | 1    | 0.235   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 1    | 0.282   | -1254641639, 1253696635|
   * | Safelist Sum         | 2    | 0.259   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 2    | 0.22    | -1254641639, 1253696635|
   * | Safelist Sum         | 3    | 0.23    | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 3    | 0.271   | -1254641639, 1253696635|
   * | Safelist Sum         | 4    | 0.251   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 4    | 0.263   | -1254641639, 1253696635|
   * </pre>
   */
  public static class UnsafeTester {

    static final int SIZE = 40000000; // 40000000 uses ~3.1GiB of RAM. TODO work out what I expect
    static final Stopwatch stopwatch = Stopwatch.createUnstarted();

    public void go() {

// Path: unsafe-tests/src/main/java/net/bramp/unsafe/examples/LongPoint.java
// public class LongPoint implements Comparable<LongPoint> {
//   public long x;
//   public long y;
// 
//   public LongPoint(long x, long y) {
//     this.x = x;
//     this.y = y;
//   }
// 
//   public String toString() {
//     return "Point(" + x + "," + y + ")";
//   }
// 
//   @Override public boolean equals(Object obj) {
//     if (this == obj) {
//       return true;
//     }
//     if (obj == null || getClass() != obj.getClass()) {
//       return false;
//     }
//     LongPoint longPoint = (LongPoint) obj;
//     return Objects.equal(x, longPoint.x) && Objects.equal(y, longPoint.y);
//   }
// 
//   @Override public int hashCode() {
//     return Objects.hashCode(x, y);
//   }
// 
//   public int compareTo(LongPoint obj) {
//     return ComparisonChain.start().compare(x, obj.x).compare(y, obj.y).result();
//   }
// }
// 
// Path: unsafe-tests/src/main/java/net/bramp/unsafe/examples/Person.java
// public class Person {
// 
//   final String name;
//   final long birthday; // Timestamp (as returned by currentTimeMillis)
//   final char gender;
// 
//   public Person(String name, long birthday, char gender) {
//     this.name = name;
//     this.birthday = birthday;
//     this.gender = gender;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public long getBirthday() {
//     return birthday;
//   }
// 
//   public char getGender() {
//     return gender;
//   }
// 
//   /**
//    * Note: Not accurate, but only used as an example.
//    *
//    * @return the age of the person in years.
//    */
//   public int getAge() {
//     return (int) ((System.currentTimeMillis() - birthday) / 1000 / 60 / 60 / 24 / 365);
//   }
// 
//   public String toString() {
//     return "Person(" + getName() + ", " + new Date(getBirthday()) + ", " + getGender() + ")";
//   }
// }


// Path: unsafe-benchmark/src/main/java/net/bramp/unsafe/Main.java
import net.bramp.unsafe.examples.LongPoint;
import net.bramp.unsafe.examples.Person;
import com.google.common.base.Stopwatch;
import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.TimeUnit;

    System.out
        .printf("Person len:%d header:%d\n", UnsafeHelper.sizeOf(p), UnsafeHelper.headerSize(p));
    UnsafeHelper.hexDump(System.out, p);
  }

  /**
   * <pre>
   * _________________________________________________________________
   * | Test                 | Trial| Time (s)| Extra                  |
   * |================================================================|
   * | Create               | 0    | 19.281  |                        |
   * | Safelist Sum         | 0    | 0.208   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 0    | 0.448   | -1254641639, 1253696635|
   * | Safelist Sum         | 1    | 0.235   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 1    | 0.282   | -1254641639, 1253696635|
   * | Safelist Sum         | 2    | 0.259   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 2    | 0.22    | -1254641639, 1253696635|
   * | Safelist Sum         | 3    | 0.23    | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 3    | 0.271   | -1254641639, 1253696635|
   * | Safelist Sum         | 4    | 0.251   | -1254641639, 1253696635|
   * | Unsafelist Sum (copy)| 4    | 0.263   | -1254641639, 1253696635|
   * </pre>
   */
  public static class UnsafeTester {

    static final int SIZE = 40000000; // 40000000 uses ~3.1GiB of RAM. TODO work out what I expect
    static final Stopwatch stopwatch = Stopwatch.createUnstarted();

    public void go() {

      final ArrayList<LongPoint> safeList = new ArrayList<LongPoint>(SIZE);