/** {@inheritDoc} */
  @Override
  public long[][] getProcessorCpuLoadTicks() {
    long[][] ticks = new long[logicalProcessorCount][4];

    int machPort = SystemB.INSTANCE.mach_host_self();

    IntByReference procCount = new IntByReference();
    PointerByReference procCpuLoadInfo = new PointerByReference();
    IntByReference procInfoCount = new IntByReference();
    if (0
        != SystemB.INSTANCE.host_processor_info(
            machPort, SystemB.PROCESSOR_CPU_LOAD_INFO, procCount, procCpuLoadInfo, procInfoCount)) {
      LOG.error("Failed to update CPU Load. Error code: " + Native.getLastError());
      return ticks;
    }

    int[] cpuTicks = procCpuLoadInfo.getValue().getIntArray(0, procInfoCount.getValue());
    for (int cpu = 0; cpu < procCount.getValue(); cpu++) {
      for (int j = 0; j < 4; j++) {
        int offset = cpu * SystemB.CPU_STATE_MAX;
        ticks[cpu][0] = FormatUtil.getUnsignedInt(cpuTicks[offset + SystemB.CPU_STATE_USER]);
        ticks[cpu][1] = FormatUtil.getUnsignedInt(cpuTicks[offset + SystemB.CPU_STATE_NICE]);
        ticks[cpu][2] = FormatUtil.getUnsignedInt(cpuTicks[offset + SystemB.CPU_STATE_SYSTEM]);
        ticks[cpu][3] = FormatUtil.getUnsignedInt(cpuTicks[offset + SystemB.CPU_STATE_IDLE]);
      }
    }
    return ticks;
  }
 /** {@inheritDoc} */
 @Override
 public long[] getSystemCpuLoadTicks() {
   long[] ticks = new long[curTicks.length];
   int machPort = SystemB.INSTANCE.mach_host_self();
   HostCpuLoadInfo cpuLoadInfo = new HostCpuLoadInfo();
   if (0
       != SystemB.INSTANCE.host_statistics(
           machPort,
           SystemB.HOST_CPU_LOAD_INFO,
           cpuLoadInfo,
           new IntByReference(cpuLoadInfo.size()))) {
     LOG.error("Failed to get System CPU ticks. Error code: " + Native.getLastError());
     return ticks;
   }
   // Switch order to match linux
   ticks[0] = cpuLoadInfo.cpu_ticks[SystemB.CPU_STATE_USER];
   ticks[1] = cpuLoadInfo.cpu_ticks[SystemB.CPU_STATE_NICE];
   ticks[2] = cpuLoadInfo.cpu_ticks[SystemB.CPU_STATE_SYSTEM];
   ticks[3] = cpuLoadInfo.cpu_ticks[SystemB.CPU_STATE_IDLE];
   return ticks;
 }