public static void main(String[] args) {
    final Integer[] array = new Integer[2000000];
    final Random random = new Random();
    for (int i = 0; i < array.length; ++i) {
      array[i] = random.nextInt(100);
    }

    final Map<String, Sorter> sorters = new LinkedHashMap<String, Sorter>();
    sorters.put("Arrays.sort", new Sorter() {
      @Override
      protected int compare(int i, int j) { throw new UnsupportedOperationException(); }
      @Override
      protected void swap(int i, int j) { throw new UnsupportedOperationException(); }
      @Override
      public void sort(int from, int to) {
        if (from == 0 && to == array.length) {
          Arrays.sort(array);
        } else {
          throw new Error();
        }
      }
    });
    sorters.put("IntroSorter", new ArrayIntroSorter<Integer>(array));
    sorters.put("HeapSorter", new ArrayHeapSorter<Integer>(array));
    sorters.put("TernaryHeapSorter", new ArrayTernaryHeapSorter<Integer>(array));
    sorters.put("MergeSorter", new ArrayMergeSorter<Integer>(array, array.length));
    sorters.put("InPlaceMergeSorter", new ArrayInPlaceMergeSorter<Integer>(array));
    sorters.put("TimSorter", new ArrayTimSorter<Integer>(array, array.length/2));

    long start = System.nanoTime();
    // JVM warming
    while (System.nanoTime() - start < 10L * 1000 * 1000 * 1000) {
      for (Sorter sorter : sorters.values()) {
        Order.RANDOM.prepare(array);
        sorter.sort(0, array.length);
      }
    }
    for (Order order : Order.values()) {
      System.out.print('\t');
      System.out.print(order);
    }
    System.out.println();
    for (int i = 0; i < 10; ++i) {
      for (Map.Entry<String, Sorter> entry : sorters.entrySet()) {
        final Sorter sorter = entry.getValue();
        System.out.print(entry.getKey());
        for (Order order : Order.values()) {
          order.prepare(array);
          start = System.nanoTime();
          sorter.sort(0, array.length);
          final long time = (System.nanoTime() - start) / 1000 / 1000;
          System.out.print('\t');
          System.out.print(time); // ms
        }
        System.out.println();
      }
    }
  }