SourceForge.net Logo
Home

PerfUtil Java API: CpuUtil class




CpuUtil

     //
     // Constructs CpuUtil object
     //
     // - Initializes public data members to 0
     // - Create instance of idle/busy/intr/cycles arrays
     // - Create instance of idle_pc/busy_pc/intr_pc/cycles_pc arrays
     //
     public CpuUtil();




CpuUtil Public Data Members

     //
     // Data members set by GetRawUtilizationCounters() method
     //
     long[] idle;        // AI idle counter
     long[] busy;        // AI busy counter
     long[] intr;        // AI interrupt counter
     long[] cycles;      // AI time stamp

     //
     // Data members set by GetCpuUtilization() method
     //
     float[] idle_pc;    // %time each processor is idle
     float[] busy_pc;    // %time each processor is busy
     float[] intr_pc;    // %time each processor spent handling interrupts

     //
     // Data members set by GetSystemUtilization() method
     //
     float sys_busy_pc;  // %time system is busy
     float sys_idle_pc;  // %time system is idle
     float sys_intr_pc;  // %time system spent handling interrupts




Init

     //
     // Initialize CPU Utilization measurement facility
     //
     // Returns:
     // - 0:        success
     // - non-zero: error initializing
     //
     native int Init();




Terminate

     //
     // Terminate CPU Utilization measurement facility
     //
     native void Terminate();




GetRawUtilizationCounters

     //
     // Get raw per-CPU utilization counters.
     //
     // Returns:
     // - 0:        success
     // - non-zero: errors
     //
     // Sets:
     // - idle[]
     // - busy[]
     // - intr[]
     // - cycles[]
     //
     // Notes:
     // - Counter arrays are indexed by processor
     // - Maximum valid index is (CpuCnt - 1)
     // - Must be invoked prior to accessing idle, busy, intr or cycles
     //   otherwise their values are undefined.
     // - Must be invoked prior to calling GetCpuUtilization() or
     //   GetSystemUtilization().
     // - Useful when you want to do utilization calculations yourself.
     //
     int GetRawUtilizationCounters();




GetCpuUtilization

     //
     // Get per-CPU utilization percentages.
     //
     // Returns:
     // - 0:        success
     // - non-zero: errors
     //
     // Sets:
     // - busy_pc[]
     // - idle_pc[]
     // - intr_pc[]
     //
     // Notes:
     // - You must invoke GetRawUtilizationCounters() *BEFORE*
     //   invoking GetCpuUtilization().
     // - Must be invoked prior to accessing busy_pc, idle_pc,
     //   or intr_pc otherwise their values are undefined.
     // - Percent utilization is calculated either since the last
     //   GetCpuUtilization(), GetSystemUtilization, or since Init().
     //
     int GetCpuUtilization();




GetSystemUtilization

     //
     // Get system-wide utilization percentages.
     // System-wide percentages are averaged over the number of processors.
     //
     // Returns:
     // - 0:        success
     // - non-zero: errors
     //
     // Sets:
     // - sys_busy_pc
     // - sys_idle_pc
     // - sys_intr_pc
     //
     // Notes:
     // - You must invoke GetRawUtilizationCounters() *BEFORE*
     //   invoking GetSystemUtilization().
     // - Must be invoked prior to accessing sys_busy_pc, sys_idle_pc,
     //   or sys_intr_pc otherwise their values are undefined.
     // - Percent utilization is calculated either since the last
     //   GetCpuUtilization(), GetSystemUtilization, or since Init().
     //
     int GetSystemUtilization();




IsSupported

     //
     // Returns whether (true) or not (false) the CPU Utilization measurement
     // facility is supported.
     //
     native boolean IsSupported();




IsActive

     //
     // Returns whether (TRUE) or not (FALSE) the AI facility is active.
     //
     // Returns:
     // - true:   AI facility has been initialized and is active
     // - false:  AI facility is not active
     //
     native boolean IsActive();