Utility function that returns a Map containing cpu usages for threads. Output will be sorted
based on the {@link CpuUsageComparator} passed.

@param cmp order to use for the results
339960
public Map<String, Object> getThreadCpuUsages(CpuUsageComparator cmp) {
    final CpuUsage overall = getOverallCpuUsage();
    final List<CpuUsage> usages = getThreadCpuUsages();
    final Map<String, Object> result = new HashMap<>();

    Collections.sort(usages, cmp);

    final Date now = new Date();
    result.put(CURRENT_TIME, now.getTime());

    final long uptimeMillis = ManagementFactory.getRuntimeMXBean().getUptime();
    final long uptimeNanos = TimeUnit.NANOSECONDS.convert(uptimeMillis, TimeUnit.MILLISECONDS);
    result.put(UPTIME_MS, uptimeMillis);

    final Map<String, Long> jvmUsageTime = new HashMap<>();
    jvmUsageTime.put(ONE_MIN, overall.getOneMinute());
    jvmUsageTime.put(FIVE_MIN, overall.getFiveMinute());
    jvmUsageTime.put(FIFTEEN_MIN, overall.getFifteenMinute());
    jvmUsageTime.put(OVERALL, overall.getOverall());
    result.put(JVM_USAGE_TIME, jvmUsageTime);

    final Map<String, Double> jvmUsagePercent = new HashMap<>();
    final int numProcs = Runtime.getRuntime().availableProcessors();
    jvmUsagePercent.put(ONE_MIN, toPercent(overall.getOneMinute(),
        ONE_MINUTE_NANOS * numProcs));
    jvmUsagePercent.put(FIVE_MIN, toPercent(overall.getFiveMinute(),
        FIVE_MINUTE_NANOS * numProcs));
    jvmUsagePercent.put(FIFTEEN_MIN, toPercent(overall.getFifteenMinute(),
        FIFTEEN_MINUTE_NANOS * numProcs));
    jvmUsagePercent.put(OVERALL, toPercent(overall.getOverall(), uptimeNanos * numProcs));
    result.put(JVM_USAGE_PERCENT, jvmUsagePercent);

    List<Map<String, Object>> threads = new ArrayList<>();
    for (CpuUsage usage : usages) {
      Map<String, Object> threadInfo = new HashMap<>();
      threadInfo.put(ONE_MIN, toPercent(usage.getOneMinute(), overall.getOneMinute()));
      threadInfo.put(FIVE_MIN, toPercent(usage.getFiveMinute(), overall.getFiveMinute()));
      threadInfo.put(FIFTEEN_MIN, toPercent(usage.getFifteenMinute(),
          overall.getFifteenMinute()));
      threadInfo.put(OVERALL, toPercent(usage.getOverall(), overall.getOverall()));
      threadInfo.put(ID, usage.getThreadId());
      threadInfo.put(NAME, usage.getName());
      threads.add(threadInfo);
    }
    result.put(THREADS, threads);
    return result;
  }
657317
def ver_cmp(ver1, ver2):
    

    return cmp(
        pkg_resources.parse_version(ver1), pkg_resources.parse_version(ver2)
    )
435540
public double getCumulativeElapsedTimeAllCurrentThread() {
	  double sum = 0;
	  
	  Accumulator acc = getAccForThread();
	  if (acc == null) {
		  return sum;
	  }

      for (int i = 1; i <= ProfilingEvent.EXECUTED.ordinal(); ++i) {
         sum += acc.accumulatedTimes[i];
      }
      
      return sum;
   }
126292
private Map<Integer, List<InstanceId>> getRoundRobinAllocation(
      int numContainer, Map<String, Integer> parallelismMap) {
    Map<Integer, List<InstanceId>> allocation = new HashMap<>();
    int totalInstance = TopologyUtils.getTotalInstance(parallelismMap);
    if (numContainer < 1) {
      throw new RuntimeException(String.format("Invlaid number of container: %d", numContainer));
    } else if (numContainer > totalInstance) {
      throw new RuntimeException(
          String.format("More containers (%d) allocated than instances (%d).",
              numContainer, totalInstance));
    }

    for (int i = 1; i <= numContainer; ++i) {
      allocation.put(i, new ArrayList<>());
    }

    int index = 1;
    int globalTaskIndex = 1;

    // To ensure we spread out the big instances first
    // Only sorting by RAM here because only RAM can be explicitly capped by JVM processes
    List<String> sortedInstances = getSortedRAMComponents(parallelismMap.keySet()).stream()
        .map(ResourceRequirement::getComponentName).collect(Collectors.toList());
    for (String component : sortedInstances) {
      int numInstance = parallelismMap.get(component);
      for (int i = 0; i < numInstance; ++i) {
        allocation.get(index).add(new InstanceId(component, globalTaskIndex, i));
        index = (index == numContainer) ? 1 : index + 1;
        globalTaskIndex++;
      }
    }
    return allocation;
  }
288129
@SuppressWarnings("rawtypes")
    public static <T> List<T> topp(final Collection<? extends T> c, final int fromIndex, final int toIndex, final int n, final Comparator<? super T> cmp) {
        N.checkArgNotNegative(n, "n");

        if (n == 0) {
            return new ArrayList<>();
        } else if (n >= toIndex - fromIndex) {
            if (fromIndex == 0 && toIndex == c.size()) {
                return new ArrayList<>(c);
            } else {
                final List<T> res = new ArrayList<>(toIndex - fromIndex);
                final Iterator<? extends T> iter = c.iterator();
                T e = null;

                for (int i = 0; i < toIndex && iter.hasNext(); i++) {
                    e = iter.next();

                    if (i < fromIndex) {
                        continue;
                    }

                    res.add(e);
                }

                return res;
            }
        }

        final Comparator<Indexed<T>> comparator = cmp == null ? (Comparator) new Comparator<Indexed<Comparable>>() {
            @Override
            public int compare(final Indexed<Comparable> o1, final Indexed<Comparable> o2) {
                return N.compare(o1.value(), o2.value());
            }
        } : new Comparator<Indexed<T>>() {
            @Override
            public int compare(final Indexed<T> o1, final Indexed<T> o2) {
                return cmp.compare(o1.value(), o2.value());
            }
        };

        final Queue<Indexed<T>> heap = new PriorityQueue<>(n, comparator);

        if (c instanceof List && c instanceof RandomAccess) {
            final List<T> list = (List<T>) c;
            Indexed<T> indexed = null;
            T e = null;

            for (int i = fromIndex; i < toIndex; i++) {
                e = list.get(i);

                indexed = Indexed.of(e, i);

                if (heap.size() >= n) {
                    if (comparator.compare(heap.peek(), indexed) < 0) {
                        heap.poll();
                        heap.add(indexed);
                    }
                } else {
                    heap.offer(indexed);
                }
            }
        } else {
            final Iterator<? extends T> iter = c.iterator();
            Indexed<T> indexed = null;
            T e = null;

            for (int i = 0; i < toIndex && iter.hasNext(); i++) {
                e = iter.next();

                if (i < fromIndex) {
                    continue;
                }

                indexed = Indexed.of(e, i);

                if (heap.size() >= n) {
                    if (comparator.compare(heap.peek(), indexed) < 0) {
                        heap.poll();
                        heap.add(indexed);
                    }
                } else {
                    heap.offer(indexed);
                }
            }
        }

        final Indexed<T>[] arrayOfIndexed = heap.toArray(new Indexed[heap.size()]);

        N.sort(arrayOfIndexed, new Comparator<Indexed<T>>() {
            @Override
            public int compare(final Indexed<T> o1, final Indexed<T> o2) {
                return o1.index() - o2.index();
            }
        });

        final List<T> res = new ArrayList<>(arrayOfIndexed.length);

        for (int i = 0, len = arrayOfIndexed.length; i < len; i++) {
            res.add(arrayOfIndexed[i].value());
        }

        return res;
    }
164544
public int getCpuUsage(String nodeID) {
		if (this.nodeID.equals(nodeID)) {
			return monitor.getTotalCpuPercent();
		}
		NodeDescriptor node = nodes.get(nodeID);
		return node == null ? 0 : node.cpu;
	}
533782
function(range) {
      var stats = {};
      stats.total = 0;

      if (!this.timeSlices)
        return stats;

      function addStatsForSlice(threadTimeSlice) {
        var freqRange = tr.b.Range.fromExplicitRange(threadTimeSlice.start,
            threadTimeSlice.end);
        var intersection = freqRange.findIntersection(range);

        if (threadTimeSlice.schedulingState ==
            tr.model.SCHEDULING_STATE.RUNNING) {
          var cpu = threadTimeSlice.cpuOnWhichThreadWasRunning;
          if (!(cpu.cpuNumber in stats))
            stats[cpu.cpuNumber] = 0;

          stats[cpu.cpuNumber] += intersection.duration;
          stats.total += intersection.duration;
        }
      }

      tr.b.iterateOverIntersectingIntervals(this.timeSlices,
                                            function(x) { return x.start; },
                                            function(x) { return x.end; },
                                            range.min,
                                            range.max,
                                            addStatsForSlice);
      return stats;
    }
296338
public static <T> T median(final T[] a, Comparator<? super T> cmp) {
        N.checkArgNotNullOrEmpty(a, "The spcified array 'a' can not be null or empty");

        return median(a, 0, a.length, cmp);
    }
824895
@JRubyMethod(name = "<=>")
    public static IRubyObject cmp(IRubyObject alias1, IRubyObject alias2) {
        IRubyObject str1 = (IRubyObject)((RubyObject)alias1).fastGetInstanceVariable("@name");
        IRubyObject str2 = (IRubyObject)((RubyObject)alias2).fastGetInstanceVariable("@name");
        return str1.callMethod(alias1.getRuntime().getCurrentContext(), "<=>", str2);
    }
1173978
def _get_cpu_info_from_kstat():
	'''
	
	'''
	try:
		# Just return {} if there is no isainfo or kstat
		if not DataSource.has_isainfo() or not DataSource.has_kstat():
			return {}

		# If isainfo fails return {}
		returncode, flag_output = DataSource.isainfo_vb()
		if flag_output == None or returncode != 0:
			return {}

		# If kstat fails return {}
		returncode, kstat = DataSource.kstat_m_cpu_info()
		if kstat == None or returncode != 0:
			return {}

		# Various fields
		vendor_id = kstat.split('\tvendor_id ')[1].split('\n')[0].strip()
		processor_brand = kstat.split('\tbrand ')[1].split('\n')[0].strip()
		stepping = int(kstat.split('\tstepping ')[1].split('\n')[0].strip())
		model = int(kstat.split('\tmodel ')[1].split('\n')[0].strip())
		family = int(kstat.split('\tfamily ')[1].split('\n')[0].strip())

		# Flags
		flags = flag_output.strip().split('\n')[-1].strip().lower().split()
		flags.sort()

		# Convert from GHz/MHz string to Hz
		scale = 6
		hz_advertised = kstat.split('\tclock_MHz ')[1].split('\n')[0].strip()
		hz_advertised = _to_decimal_string(hz_advertised)

		# Convert from GHz/MHz string to Hz
		hz_actual = kstat.split('\tcurrent_clock_Hz ')[1].split('\n')[0].strip()
		hz_actual = _to_decimal_string(hz_actual)

		info = {
		'vendor_id_raw' : vendor_id,
		'brand_raw' : processor_brand,

		'hz_advertised_friendly' : _hz_short_to_friendly(hz_advertised, scale),
		'hz_actual_friendly' : _hz_short_to_friendly(hz_actual, 0),
		'hz_advertised' : _hz_short_to_full(hz_advertised, scale),
		'hz_actual' : _hz_short_to_full(hz_actual, 0),

		'stepping' : stepping,
		'model' : model,
		'family' : family,
		'flags' : flags
		}

		info = {k: v for k, v in info.items() if v}
		return info
	except:
		return {}
735428
public /*@ pure @*/ int cmp(FDBigInteger other) {
        int aSize = nWords + offset;
        int bSize = other.nWords + other.offset;
        if (aSize > bSize) {
            return 1;
        } else if (aSize < bSize) {
            return -1;
        }
        int aLen = nWords;
        int bLen = other.nWords;
        while (aLen > 0 && bLen > 0) {
            int a = data[--aLen];
            int b = other.data[--bLen];
            if (a != b) {
                return ((a & LONG_MASK) < (b & LONG_MASK)) ? -1 : 1;
            }
        }
        if (aLen > 0) {
            return checkZeroTail(data, aLen);
        }
        if (bLen > 0) {
            return -checkZeroTail(other.data, bLen);
        }
        return 0;
    }
242171
public static <K, V> void forEachKeyValue(
            Map<K, V> map,
            Procedure2<? super K, ? super V> procedure,
            int minForkSize,
            int taskCount)
    {
        if (map.size() > minForkSize)
        {
            Procedure<Pair<K, V>> pairProcedure = new PairProcedure<K, V>(procedure);
            ParallelIterate.forEach(MapIterate.toListOfPairs(map), new PassThruProcedureFactory<Procedure<Pair<K, V>>>(pairProcedure), new PassThruCombiner<Procedure<Pair<K, V>>>(), minForkSize, taskCount);
        }
        else
        {
            MapIterate.forEachKeyValue(map, procedure);
        }
    }
543100
function StablePriorityQueue(comparator) {
    this.array = [];
    this.size = 0;
    this.runningcounter = 0;
    this.compare = comparator || defaultcomparator;
    this.stable_compare = function(a, b) {
      var cmp = this.compare(a.value,b.value);
      return (cmp < 0) || ( (cmp == 0) && (a.counter < b.counter) );
    }
}
1255015
public static <T> T max(final T[] a, final Comparator<? super T> cmp) {
        N.checkArgNotNullOrEmpty(a, "The spcified array 'a' can not be null or empty");

        return max(a, 0, a.length, cmp);
    }
468620
def CMP(self, params):
        
        Rm, Rn = self.get_two_parameters(self.TWO_PARAMETER_COMMA_SEPARATED, params)

        if self.is_register(Rn):
            # CMP Rm, Rn
            self.check_arguments(R0_thru_R14=(Rm, Rn))

            def CMP_func():
                self.set_NZCV_flags(self.register[Rm], self.register[Rn],
                                    self.register[Rm] - self.register[Rn], 'sub')
        else:
            # CMP Rm, #imm8
            self.check_arguments(R0_thru_R14=(Rm,), imm8=(Rn,))

            def CMP_func():
                tmp = self.convert_to_integer(Rn[1:])
                self.set_NZCV_flags(self.register[Rm], tmp,
                                    self.register[Rm] - tmp, 'sub')

        return CMP_func
613100
public static <T> T min(final T[] a, final Comparator<? super T> cmp) {
        N.checkArgNotNullOrEmpty(a, "The spcified array 'a' can not be null or empty");

        return min(a, 0, a.length, cmp);
    }
23066
public final void cmpps(XMMRegister dst, XMMRegister src, Immediate imm8)
  {
    emitX86(INST_CMPPS, dst, src, imm8);
  }