Beispiel #1
0
 private Comparator<PolicyStats> makeComparator() {
   switch (settings.report().sortBy().toLowerCase()) {
     case "policy":
       return Comparator.comparing(PolicyStats::name);
     case "hit rate":
       return Comparator.comparingDouble(PolicyStats::hitRate);
     case "hits":
       return Comparator.comparingLong(PolicyStats::hitCount);
     case "misses":
       return Comparator.comparingLong(PolicyStats::missCount);
     case "evictions":
       return Comparator.comparingLong(PolicyStats::evictionCount);
     case "steps":
       return Comparator.comparingLong(PolicyStats::operationCount);
     case "time":
       return Comparator.comparingLong(stats -> stats.stopwatch().elapsed(TimeUnit.NANOSECONDS));
     default:
       throw new IllegalArgumentException("Unknown sort order: " + settings.report().sortBy());
   }
 }
 /**
  * Sort a given list of VMs by descending order of CPU utilization.
  *
  * @param vmList the vm list to be sorted
  * @param currentSimulationTime the current simulation time to get the current CPU utilization for
  *     each Vm
  */
 public static void sortByCpuUtilization(List<? extends Vm> vmList, double currentSimulationTime) {
   Comparator<Vm> comparator =
       Comparator.comparingDouble(vm -> vm.getTotalUtilizationOfCpuMips(currentSimulationTime));
   vmList.sort(comparator.reversed());
 }