SourceForge.net Logo
Home

PerfUtil Java API: JPerf class




JPerf

     //
     // Constructs JPerf object
     // - Initializes public data members to 0
     // - Create instance of PerfCtrs[] array
     //
     // It is a good idea to invoke GetCPUInfo(), after instatiating
     // a JPerf object, in order to initialize the CPU-related
     // members: CPU, CPUType, CPUFamily, CPUFeatures, NumCtrs and CPUSpeed
     //
     public JPerf();


     //
     // Constructs JPerf object
     // - Initializes public data members to 0
     // - Sets CPUSpeed to given speed
     // - Create instance of PerfCtrs[] array
     //
     // It is a good idea to invoke GetCPUInfo(), after instatiating
     // a JPerf object, in order to initialize the CPU-related
     // members: CPU, CPUType, CPUFamily, CPUFeatures, NumCtrs and CPUSpeed
     //
     public JPerf(int Speed);




GetCycles

     //
     // Queries native processor cycle counter. This value is
     // obtained from the RDTSC instruction.
     //
     // ***** Runs on current processor *****
     //
     // Sets:
     // - timestamp
     //
     // Notes:
     // - You should really use ReadCycles(). It incurs a lot less overhead
     //   because it doesn't need to access the object to set the "timestamp"
     //   data member.
     //
     static native void GetCycles();




ReadCycles

     //
     // Queries native processor cycle counter.
     //
     // ***** Runs on current processor *****
     //
     // Returns:
     // - 64-bit value of the Time Stamp Counter register
     //
     static native long ReadCycles();




CyclesToSeconds

     //
     // Converts cycles to seconds.
     //
     // Given two timestamps, CyclesStart and CyclesEnd, returns
     // CyclesEnd-CyclesStart in Seconds.
     //
     // Input:
     // - CyclesStart: Starting timestamp
     // - CyclesEnd:   Ending timestamp
     //
     // Returns:
     // - seconds
     //
     double CyclesToSeconds(long CyclesStart, long CyclesEnd);




CyclesToMilliseconds

     //
     // Converts cycles to milliseconds.
     //
     // Given two timestamps, CyclesStart and CyclesEnd, returns
     // CyclesEnd-CyclesStart in Milliseconds.
     //
     // Input:
     // - CyclesStart: Starting timestamp
     // - CyclesEnd:   Ending timestamp
     //
     // Returns:
     // - milliseconds
     //
     double CyclesToMilliseconds(long CyclesStart, long CyclesEnd);




CyclesToMicroseconds

     //
     // Converts cycles to microseconds.
     //
     // Given two timestamps, CyclesStart and CyclesEnd, returns
     // CyclesEnd-CyclesStart in Microseconds.
     //
     // Input:
     // - CyclesStart: Starting timestamp
     // - CyclesEnd:   Ending timestamp
     //
     // Returns:
     // - microseconds
     //
     double CyclesToMicroseconds(long CyclesStart, long CyclesEnd);




toRightJustifiedHexString

     //
     // Convert an int or long to hex and right-justify it with leading blanks.
     //
     // Input:
     // - i:           Value to convert
     // - width:       Field width in which string is right-justified
     //
     // Returns:
     // - Right-justified, leading-blank filled, string of "width" length.
     //
     static String toRightJustifiedHexString(int i, int width);
     static String toRightJustifiedHexString(int i);
     static String toRightJustifiedHexString(long i, int width);
     static String toRightJustifiedHexString(long i);




toRightJustifiedHexString_LZ

     //
     // Convert an int or long to hex and right-justify it with leading zeros.
     //
     // Input:
     // - i:           Value to convert
     // - width:       Field width in which string is right-justified
     //
     // Returns:
     // - Right-justified, leading-zero filled, hex string of "width" length.
     //
     static String toRightJustifiedHexString_LZ(int i, int width);
     static String toRightJustifiedHexString_LZ(int i);
     static String toRightJustifiedHexString_LZ(long i, int width);
     static String toRightJustifiedHexString_LZ(long i);




toRightJustifiedString

     //
     // Right-justify an int or long with leading blanks.
     //
     // Input:
     // - i:           Value to convert
     // - width:       Field width in which string is right-justified
     //
     // Returns:
     // - Right-justified, leading-blank filled, string of "width" length.
     //
     static String toRightJustifiedString(int i, int width);
     static String toRightJustifiedString(long i, int width);




toRightJustifiedString_LZ

     //
     // Right-justify an int or long with leading zeros.
     //
     // Input:
     // - i:           Value to convert
     // - width:       Field width in which string is right-justified
     //
     // Returns:
     // - Right-justified, leading-zero filled, string of "width" length.
     //
     static String toRightJustifiedString_LZ(int i, int width);
     static String toRightJustifiedString_LZ(long i, int width);




RcToString

     //
     // Convert a PerfUtil return code to its name.
     //
     // Input:
     // - rc:          Return code.
     //
     // Returns:
     // - String containing the human-readable name corresponding to rc.
     //   Returns "Not a PerfUtil return code" for return codes that do not
     //   originate in PerfUtil.
     //
     static String RcToString(int rc);