public static RLESparseResourceAllocation merge(ResourceCalculator resCalc,
      Resource clusterResource, RLESparseResourceAllocation a,
      RLESparseResourceAllocation b, RLEOperator operator, long start, long end)
      throws PlanningException {
    NavigableMap<Long, Resource> cumA =
        a.getRangeOverlapping(start, end).getCumulative();
    NavigableMap<Long, Resource> cumB =
        b.getRangeOverlapping(start, end).getCumulative();
    NavigableMap<Long, Resource> out =
        merge(resCalc, clusterResource, cumA, cumB, start, end, operator);
    return new RLESparseResourceAllocation(out, resCalc);
  }
@Test
  @Ignore
  public void testMergeSpeed() throws PlanningException {

    for (int j = 0; j < 100; j++) {
      TreeMap<Long, Resource> a = new TreeMap<>();
      TreeMap<Long, Resource> b = new TreeMap<>();
      Random rand = new Random();
      long startA = 0;
      long startB = 0;

      for (int i = 0; i < 1000 + rand.nextInt(9000); i++) {
        startA += rand.nextInt(100);
        startB += rand.nextInt(100);
        a.put(startA,
            Resource.newInstance(rand.nextInt(10240), rand.nextInt(10)));
        b.put(startB,
            Resource.newInstance(rand.nextInt(10240), rand.nextInt(10)));
      }

      RLESparseResourceAllocation rleA =
          new RLESparseResourceAllocation(a, new DefaultResourceCalculator());
      RLESparseResourceAllocation rleB =
          new RLESparseResourceAllocation(b, new DefaultResourceCalculator());

      long start = System.currentTimeMillis();
      RLESparseResourceAllocation out =
          RLESparseResourceAllocation.merge(new DefaultResourceCalculator(),
              Resource.newInstance(100 * 128 * 1024, 100 * 32), rleA, rleB,
              RLEOperator.add, Long.MIN_VALUE, Long.MAX_VALUE);
      long end = System.currentTimeMillis();

      System.out.println(" Took: " + (end - start) + "ms ");
    }

  }