package com.github.lwhite1.tablesaw.testutil;

/**
 *
 */
public class IntegerBenchmarks {
}

@@ -44,50 +44,2221 @@
 l;%0A%0A
-/**%0A *%0A */%0Apublic class IntegerBenchmarks %7B%0A%7D%0A
+import it.unimi.dsi.fastutil.ints.IntArrayList;%0Aimport it.unimi.dsi.fastutil.ints.IntRBTreeSet;%0Aimport me.lemire.integercompression.differential.IntegratedIntCompressor;%0Aimport org.apache.commons.lang3.RandomUtils;%0Aimport org.github.jamm.MemoryMeter;%0Aimport org.roaringbitmap.RoaringBitmap;%0A%0A/**%0A * Benchmarks on representations of integers using a variety of approaches and scenarios,%0A * where the scenarios vary the number of ints represented as well as the size of the population%0A * that they are drawn from.%0A *%0A * Note that we use jamm to measures the number of bytes. To run jamm, you need to execute this test%0A * with the following jvm arguments%0A * -javaagent:jamm-0.3.1.jar%0A *%0A * Jamm needs to be in the pom to compile and needs to be in the java path to execute%0A */%0Apublic class IntegerBenchmarks %7B%0A%0A  public static void main(String%5B%5D args) %7B%0A%0A    MemoryMeter meter = new MemoryMeter();%0A%0A    // test sets of ints ranging in size from 0 to CYCLES%0A    int CYCLES = 5000;%0A    int POPULATION_SIZE = 50_000_000;%0A%0A    IntArrayList list = new IntArrayList();%0A    IntArrayList list2 = new IntArrayList();%0A    RoaringBitmap bitmap = new RoaringBitmap();%0A%0A    // In this step we sort the ints%0A    IntRBTreeSet testData = new IntRBTreeSet();%0A    for (int i = 0; i %3C CYCLES; i++) %7B%0A      int x = RandomUtils.nextInt(0, POPULATION_SIZE);%0A      testData.add(x);%0A    %7D%0A%0A    IntegratedIntCompressor iic = new IntegratedIntCompressor();%0A    int%5B%5D compressed;%0A    int count = 1;%0A    for (int i : testData) %7B%0A      list.add(i);%0A      list2.add(i);%0A      list2.trim();%0A      bitmap.add(i);%0A%0A      compressed = iic.compress(list.elements());%0A      System.out.println();%0A      System.out.println(count);%0A      System.out.println(%22IntArrayList:         %22 + meter.measureDeep(list));%0A      System.out.println(%22Trimmed IntArrayList: %22 + meter.measureDeep(list2));%0A      System.out.println(%22Trimmed int%5B%5D:        %22 + meter.measureDeep(list2.elements()));%0A      System.out.println(%22Array:                %22 + meter.measureDeep(list2.elements()));%0A      System.out.println(%22Bitmap:               %22 + meter.measureDeep(bitmap));%0A      System.out.println(%22FastPfor:             %22 + meter.measureDeep(compressed));%0A      count++;%0A    %7D%0A  %7D%0A%7D

test comparing integer array representations for their memory usage