suramadu.util.time
Class Time

java.lang.Object
  extended bysuramadu.util.time.Time

public class Time
extends java.lang.Object

This class is a utility class for measuring and calculating very high-resolution time based on th enumber of machine cycles between events being measured. It contains two native methods, getCycles(), and getTime() for retrieving low level time measurements from the underlying operating system. (See method descriptions for details of their functionality).


Field Summary
static long cps
          This variable contains the clock speed of the microprocessor on which this class is running measured in cycles per second (cps).
static java.lang.String NATIVE_LIBRARY_NAME
          Native library name
static java.lang.String TIME_MIN
          String for indicating unit type: minutes
static java.lang.String TIME_MS
          String for indicating unit type: milliseconds
static java.lang.String TIME_NS
          String for indicating unit type: nanoseconds
static java.lang.String TIME_S
          String for indicating unit type: seconds
static java.lang.String TIME_US
          String for indicating unit type: microseconds
 
Constructor Summary
Time()
           
 
Method Summary
static long avgPeriod(int[] intArray, int offset)
          Given an array of ints of length n where each element represents an absolute time measurement, calculate the average period over the length of the array.
static long avgPeriod(long[] longArray, int offset)
          Given an array of ints of length n where each element represents an absolute time measurement, calculate the average period over the length of the array.
static long cyclesFromMin(long minutes)
          Calculates the number of machine cycles represented by the specified number of minutes based on the intrinsically calculated CPU speed timebase (cps).
static long cyclesFromMin(long minutes, long frequency)
          Calculates the number of machine cycles represented by the specified number of minutes based on the specified CPU speed timebase (frequency).
static long cyclesFromMs(long ms)
          Calculates the number of machine cycles represented by the specified number of milliseconds based on the intrinsically calculated CPU speed timebase (cps).
static long cyclesFromMs(long ms, long frequency)
          Calculates the number of machine cycles represented by the specified number of milliseconds based on the specified CPU speed timebase (frequency).
static long cyclesFromNs(long ns)
          Calculates the number of machine cycles represented by the specified number of nanoseconds based on the intrinsically calculated CPU speed timebase (cps).
static long cyclesFromNs(long ns, long frequency)
          Calculates the number of machine cycles represented by the specified number of nanoseconds based on the specified CPU speed timebase (frequency).
static long cyclesFromS(long seconds)
          Calculates the number of machine cycles represented by the specified number of seconds based on the intrinsically calculated CPU speed timebase (cps).
static long cyclesFromS(long seconds, long frequency)
          Calculates the number of machine cycles represented by the specified number of seconds based on the specified CPU speed timebase (frequency).
static long cyclesFromUs(long us)
          Calculates the number of machine cycles represented by the specified number of microseconds based on the intrinsically calculated CPU speed timebase (cps).
static long cyclesFromUs(long us, long frequency)
          Calculates the number of machine cycles represented by the specified number of microseconds based on the specified CPU speed timebase (frequency).
static java.lang.String formatTime(double ms_time)
          Formats to a String the specified time value in milliseconds.
static java.lang.String formatTime(double ms_time, int scale)
          Formats to a String the specified time value in milliseconds.
static long getCPS(int bounds, int loops, int tolerace, int toleranceRetries, java.lang.String output)
          Calculate the clock frequency of the processor on which it is executing.
static long getCycles()
          Get the current high resolution cycle count using inline assembly similar to 'rdtsc'.
static void getTime(long[] timeArray)
          Get the current high resolution time from the clock.
static int[] jitter(int[] intArray)
          Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from a calculated average period.
static int[] jitter(int[] intArray, int offset)
          Given an array of longs of length n where each element represents an absolute time measurement, convert the values in the array to represent deviation from a calculated average period.
static long[] jitter(long[] longArray)
          Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from a calculated average period.
static long[] jitter(long[] longArray, int offset)
          Given an array of longs of length n where each element represents an absolute time measurement, convert the values in the array to represent deviation from a calculated average period.
static int[] jitter(long period, int[] intArray)
          Given an array of ints of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.
static int[] jitter(long period, int[] intArray, int offset)
          Given an array of ints of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.
static long[] jitter(long period, long[] longArray)
          Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.
static long[] jitter(long period, long[] longArray, int offset)
          Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.
static double minFromCycles(long cycles)
          Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static double[] minFromCycles(long[] cycles)
          Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static double[] minFromCycles(long[] cycles, long frequency)
          Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static double minFromCycles(long cycles, long frequency)
          Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static long[] minFromCyclesL(long[] cycles)
          Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static long[] minFromCyclesL(long[] cycles, long frequency)
          Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static double msFromCycles(long cycles)
          Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static double[] msFromCycles(long[] cycles)
          Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static double[] msFromCycles(long[] cycles, long frequency)
          Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static double msFromCycles(long cycles, long frequency)
          Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static long[] msFromCyclesL(long[] cycles)
          Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static long[] msFromCyclesL(long[] cycles, long frequency)
          Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static double nsFromCycles(long cycles)
          Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static double[] nsFromCycles(long[] cycles)
          Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static double[] nsFromCycles(long[] cycles, long frequency)
          Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static double nsFromCycles(long cycles, long frequency)
          Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static long[] nsFromCyclesL(long[] cycles)
          Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static long[] nsFromCyclesL(long[] cycles, long frequency)
          Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static java.lang.String roundToDecimals(double time, int scale)
          Helper method that rounds a double value to a particular decimal scale
static double sFromCycles(long cycles)
          Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static double[] sFromCycles(long[] cycles)
          Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static double[] sFromCycles(long[] cycles, long frequency)
          Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static double sFromCycles(long cycles, long frequency)
          Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static long[] sFromCyclesL(long[] cycles)
          Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static long[] sFromCyclesL(long[] cycles, long frequency)
          Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static java.lang.String[] splitFormatTime(double ms_time)
          Formats a String that represents the real time value represented by the number of milliseconds specified.
static java.lang.String[] splitFormatTime(double ms_time, int scale)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String[] splitTimeFromCycles(long cycles)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String[] splitTimeFromCycles(long cycles, int scale)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String[] splitTimeFromCycles(long cycles, long frequency)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String[] splitTimeFromCycles(long cycles, long frequency, int scale)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String timeFromCycles(long cycles)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String timeFromCycles(long cycles, int scale)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String timeFromCycles(long cycles, long frequency)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static java.lang.String timeFromCycles(long cycles, long frequency, int scale)
          Formats a String that represents the real time value represented by the number of machine cycles passed in.
static double usFromCycles(long cycles)
          Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static double[] usFromCycles(long[] cycles)
          Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static double[] usFromCycles(long[] cycles, long frequency)
          Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
static double usFromCycles(long cycles, long frequency)
          Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).
static long[] usFromCyclesL(long[] cycles)
          Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.
static long[] usFromCyclesL(long[] cycles, long frequency)
          Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIME_MIN

public static final java.lang.String TIME_MIN
String for indicating unit type: minutes

See Also:
Constant Field Values

TIME_S

public static final java.lang.String TIME_S
String for indicating unit type: seconds

See Also:
Constant Field Values

TIME_MS

public static final java.lang.String TIME_MS
String for indicating unit type: milliseconds

See Also:
Constant Field Values

TIME_US

public static final java.lang.String TIME_US
String for indicating unit type: microseconds

See Also:
Constant Field Values

TIME_NS

public static final java.lang.String TIME_NS
String for indicating unit type: nanoseconds

See Also:
Constant Field Values

NATIVE_LIBRARY_NAME

public static final java.lang.String NATIVE_LIBRARY_NAME
Native library name

See Also:
Constant Field Values

cps

public static final long cps
This variable contains the clock speed of the microprocessor on which this class is running measured in cycles per second (cps). It is retrieved at static initialization of the class as a property from a file created by the ClockspeedGHz utility. If this file is not found, an attempt is made to run the ClockspeedGHz utility to generate it before proceeding. This can be very time consuming.

Constructor Detail

Time

public Time()
Method Detail

getCycles

public static long getCycles()
Get the current high resolution cycle count using inline assembly similar to 'rdtsc'.

Returns:
The current microprocessor cycle count

getCPS

public static long getCPS(int bounds,
                          int loops,
                          int tolerace,
                          int toleranceRetries,
                          java.lang.String output)
Calculate the clock frequency of the processor on which it is executing.

Returns:
The number of cycles per second (CPS) at which the processor runs.

getTime

public static void getTime(long[] timeArray)
Get the current high resolution time from the clock. The first array element is the seconds value, and the second array element is the nanoseconds value. (This data structure is consistent with Linux's formattig of tv_struct).

Parameters:
timeArray - Writes the first two elements to the specified array of type long, the first element indicates the number of milliseconds, the second indicates the number of nanoseconds. This time format is analogous to the format used in Linux to define time, as specified in the OS data structure, tv_struct.

avgPeriod

public static long avgPeriod(int[] intArray,
                             int offset)
Given an array of ints of length n where each element represents an absolute time measurement, calculate the average period over the length of the array.

Parameters:
intArray - array of times to be converted
offset - begin calculations from offset position in intArray
Returns:
average period or -1 if parameters are inappropriate
See Also:
Collection

avgPeriod

public static long avgPeriod(long[] longArray,
                             int offset)
Given an array of ints of length n where each element represents an absolute time measurement, calculate the average period over the length of the array.

Parameters:
longArray - array of times to be converted
offset - begin calculations from offset position in longArray
Returns:
average period or -1 if parameters are inappropriate
See Also:
Collection

jitter

public static int[] jitter(int[] intArray)
Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from a calculated average period.

Parameters:
intArray - array of times to be converted
Returns:
converted array.
See Also:
Collection

jitter

public static int[] jitter(long period,
                           int[] intArray)
Given an array of ints of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.

Parameters:
period - period from which to perform jitter calculations
intArray - array of times to be converted
Returns:
converted array.
See Also:
Collection

jitter

public static long[] jitter(long[] longArray)
Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from a calculated average period.

Parameters:
longArray - array of times to be converted
Returns:
converted array.
See Also:
Collection

jitter

public static long[] jitter(long period,
                            long[] longArray)
Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.

Parameters:
period - period from which to perform jitter calculations
longArray - array of times to be converted
Returns:
converted array.
See Also:
Collection

jitter

public static int[] jitter(int[] intArray,
                           int offset)
Given an array of longs of length n where each element represents an absolute time measurement, convert the values in the array to represent deviation from a calculated average period.

Parameters:
intArray - array of times to be converted
offset - begin calculations from offset position in longArray
Returns:
converted array.
See Also:
Collection

jitter

public static int[] jitter(long period,
                           int[] intArray,
                           int offset)
Given an array of ints of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.

Parameters:
period - period from which to perform jitter calculations
intArray - array of times to be converted
offset - begin calculations from offset position in intArray
Returns:
converted array.
See Also:
Collection

jitter

public static long[] jitter(long[] longArray,
                            int offset)
Given an array of longs of length n where each element represents an absolute time measurement, convert the values in the array to represent deviation from a calculated average period.

Parameters:
longArray - array of times to be converted
offset - begin calculations from offset position in longArray
Returns:
converted array.
See Also:
Collection

jitter

public static long[] jitter(long period,
                            long[] longArray,
                            int offset)
Given an array of longs of length n where each element represents an absolute time measurement, and a period that represents a periodic time in the same units as the time measurements in the array, convert the values in the array to represent deviation from the specified period.

Parameters:
period - period from which to perform jitter calculations
longArray - array of times to be converted
offset - begin calculations from offset position in longArray
Returns:
converted array.
See Also:
Collection

minFromCycles

public static double[] minFromCycles(long[] cycles)
Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of doubles representing the converted values.

minFromCycles

public static double[] minFromCycles(long[] cycles,
                                     long frequency)
Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of doubles representing the converted values.

minFromCyclesL

public static long[] minFromCyclesL(long[] cycles)
Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of longs representing the converted values.

minFromCyclesL

public static long[] minFromCyclesL(long[] cycles,
                                    long frequency)
Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of longs representing the converted values.

minFromCycles

public static double minFromCycles(long cycles)
Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
the numbe of minutes represented by the specified number of machine cycles.

minFromCycles

public static double minFromCycles(long cycles,
                                   long frequency)
Calculates the number of minutes represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of minutes represented by the specified number of machine cycles.

sFromCycles

public static double[] sFromCycles(long[] cycles)
Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of doubles representing the converted values.

sFromCycles

public static double[] sFromCycles(long[] cycles,
                                   long frequency)
Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of doubles representing the converted values.

sFromCyclesL

public static long[] sFromCyclesL(long[] cycles)
Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of longs representing the converted values.

sFromCyclesL

public static long[] sFromCyclesL(long[] cycles,
                                  long frequency)
Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of longs representing the converted values.

sFromCycles

public static double sFromCycles(long cycles)
Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
the numbe of seconds represented by the specified number of machine cycles.

sFromCycles

public static double sFromCycles(long cycles,
                                 long frequency)
Calculates the number of seconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of seconds represented by the specified number of machine cycles.

msFromCycles

public static double[] msFromCycles(long[] cycles)
Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of doubles representing the converted values.

msFromCycles

public static double[] msFromCycles(long[] cycles,
                                    long frequency)
Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of doubles representing the converted values.

msFromCyclesL

public static long[] msFromCyclesL(long[] cycles)
Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of longs representing the converted values.

msFromCyclesL

public static long[] msFromCyclesL(long[] cycles,
                                   long frequency)
Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of longs representing the converted values.

msFromCycles

public static double msFromCycles(long cycles)
Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
the numbe of milliseconds represented by the specified number of machine cycles.

msFromCycles

public static double msFromCycles(long cycles,
                                  long frequency)
Calculates the number of milliseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of milliseconds represented by the specified number of machine cycles.

usFromCycles

public static double[] usFromCycles(long[] cycles)
Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of doubles representing the converted values.

usFromCycles

public static double[] usFromCycles(long[] cycles,
                                    long frequency)
Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of doubles representing the converted values.

usFromCyclesL

public static long[] usFromCyclesL(long[] cycles)
Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of longs representing the converted values.

usFromCyclesL

public static long[] usFromCyclesL(long[] cycles,
                                   long frequency)
Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of longs representing the converted values.

usFromCycles

public static double usFromCycles(long cycles)
Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
the numbe of microseconds represented by the specified number of machine cycles.

usFromCycles

public static double usFromCycles(long cycles,
                                  long frequency)
Calculates the number of microseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of microseconds represented by the specified number of machine cycles.

nsFromCycles

public static double[] nsFromCycles(long[] cycles)
Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of doubles representing the converted values.

nsFromCycles

public static double[] nsFromCycles(long[] cycles,
                                    long frequency)
Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of doubles representing the converted values.

nsFromCyclesL

public static long[] nsFromCyclesL(long[] cycles)
Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
an array of longs representing the converted values.

nsFromCyclesL

public static long[] nsFromCyclesL(long[] cycles,
                                   long frequency)
Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (frequency) for an array of values.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
an array of longs representing the converted values.

nsFromCycles

public static double nsFromCycles(long cycles)
Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
the numbe of nanoseconds represented by the specified number of machine cycles.

nsFromCycles

public static double nsFromCycles(long cycles,
                                  long frequency)
Calculates the number of nanoseconds represented by the specified number of machine cycles based on its intrinsically calculated CPU speed timebase (cps).

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of nanoseconds represented by the specified number of machine cycles.

cyclesFromMin

public static long cyclesFromMin(long minutes)
Calculates the number of machine cycles represented by the specified number of minutes based on the intrinsically calculated CPU speed timebase (cps).

Parameters:
minutes - The number of minutes to use for the conversion.
Returns:
the numbe of machine cycles represented by the specified number of minutes.

cyclesFromMin

public static long cyclesFromMin(long minutes,
                                 long frequency)
Calculates the number of machine cycles represented by the specified number of minutes based on the specified CPU speed timebase (frequency).

Parameters:
minutes - The number of minutes to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of machine cycles represented by the specified number of minutes.

cyclesFromS

public static long cyclesFromS(long seconds)
Calculates the number of machine cycles represented by the specified number of seconds based on the intrinsically calculated CPU speed timebase (cps).

Parameters:
seconds - The number of seconds to use for the conversion.
Returns:
the numbe of machine cycles represented by the specified number of seconds.

cyclesFromS

public static long cyclesFromS(long seconds,
                               long frequency)
Calculates the number of machine cycles represented by the specified number of seconds based on the specified CPU speed timebase (frequency).

Parameters:
seconds - The number of seconds to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of machine cycles represented by the specified number of seconds.

cyclesFromMs

public static long cyclesFromMs(long ms)
Calculates the number of machine cycles represented by the specified number of milliseconds based on the intrinsically calculated CPU speed timebase (cps).

Parameters:
ms - The number of milliseconds to use for the conversion.
Returns:
the numbe of machine cycles represented by the specified number of milliseconds.

cyclesFromMs

public static long cyclesFromMs(long ms,
                                long frequency)
Calculates the number of machine cycles represented by the specified number of milliseconds based on the specified CPU speed timebase (frequency).

Parameters:
ms - The number of milliseconds to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of machine cycles represented by the specified number of milliseconds.

cyclesFromUs

public static long cyclesFromUs(long us)
Calculates the number of machine cycles represented by the specified number of microseconds based on the intrinsically calculated CPU speed timebase (cps).

Parameters:
us - The number of microseconds to use for the conversion.
Returns:
the numbe of machine cycles represented by the specified number of microseconds.

cyclesFromUs

public static long cyclesFromUs(long us,
                                long frequency)
Calculates the number of machine cycles represented by the specified number of microseconds based on the specified CPU speed timebase (frequency).

Parameters:
us - The number of microseconds to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of machine cycles represented by the specified number of microseconds.

cyclesFromNs

public static long cyclesFromNs(long ns)
Calculates the number of machine cycles represented by the specified number of nanoseconds based on the intrinsically calculated CPU speed timebase (cps).

Parameters:
ns - The number of nanoseconds to use for the conversion.
Returns:
the numbe of machine cycles represented by the specified number of nanoseconds.

cyclesFromNs

public static long cyclesFromNs(long ns,
                                long frequency)
Calculates the number of machine cycles represented by the specified number of nanoseconds based on the specified CPU speed timebase (frequency).

Parameters:
ns - The number of nanoseconds to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
the numbe of machine cycles represented by the specified number of nanoseconds.

timeFromCycles

public static java.lang.String timeFromCycles(long cycles)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the Time classes intrinsic cps timebase for its calculations. If this timebase has not been initialized, a RuntimeExcpetion will be thrown.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
String containing real-time value and its scaled units designation.

timeFromCycles

public static java.lang.String timeFromCycles(long cycles,
                                              long frequency)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the Time classes intrinsic cps timebase for its calculations. If this timebase has not been initialized, a RuntimeExcpetion will be thrown.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
String containing real-time value and its scaled units designation.

timeFromCycles

public static java.lang.String timeFromCycles(long cycles,
                                              int scale)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the Time classes intrinsic cps timebase for its calculations. If this timebase has not been initialized, a RuntimeExcpetion will be thrown.

Parameters:
cycles - The number of machine cycles to use for the conversion.
scale - the number of decimal places to which to round the result.
Returns:
String containing real-time value and its scaled units designation.

timeFromCycles

public static java.lang.String timeFromCycles(long cycles,
                                              long frequency,
                                              int scale)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the Time classes intrinsic cps timebase for its calculations. If this timebase has not been initialized, a RuntimeExcpetion will be thrown.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
scale - the number of decimal places to which to round the result.
Returns:
String containing real-time value and its scaled units designation.

splitTimeFromCycles

public static java.lang.String[] splitTimeFromCycles(long cycles)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the Time classes intrinsic cps timebase for its calculations. If this timebase has not been initialized, a RuntimeExcpetion will be thrown. It separates the result into two Strings returned in a two element array of Strings, the zeroth element being the value, the first element being a mnemonic describing the units being represented by the value.

Parameters:
cycles - The number of machine cycles to use for the conversion.
Returns:
Two element array of type String containing a formatted floating- point real-time value in its zeroth element, and a mnemonic describing the units being represented by the value in its first element.

splitTimeFromCycles

public static java.lang.String[] splitTimeFromCycles(long cycles,
                                                     long frequency)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the specified time base for its calculations. It separates the result into two Strings returned in a two element array of Strings, the zeroth element being the value, the first element being a mnemonic describing the units being represented by the value.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
Returns:
Two element array of type String containing a formatted floating- point real-time value in its zeroth element, and a mnemonic describing the units being represented by the value in its first element.

splitTimeFromCycles

public static java.lang.String[] splitTimeFromCycles(long cycles,
                                                     int scale)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the Time classes intrinsic cps timebase for its calculations. If this timebase has not been initialized, a RuntimeExcpetion will be thrown. It separates the result into two Strings returned in a two element array of Strings, the zeroth element being the value, the first element being a mnemonic describing the units being represented by the value.

Parameters:
cycles - The number of machine cycles to use for the conversion.
scale - the number of decimal places to which to round the result.
Returns:
Two element array of type String containing a formatted floating- point real-time value in its zeroth element, and a mnemonic describing the units being represented by the value in its first element.

splitTimeFromCycles

public static java.lang.String[] splitTimeFromCycles(long cycles,
                                                     long frequency,
                                                     int scale)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the specified time base for its calculations. It separates the result into two Strings returned in a two element array of Strings, the zeroth element being the value, the first element being a mnemonic describing the units being represented by the value.

Parameters:
cycles - The number of machine cycles to use for the conversion.
frequency - The number of machine cycles in a real-time second (cps). Overrides the intrinsic cps value measured at startup.
scale - the number of decimal places to which to round the result.
Returns:
Two element array of type String containing a formatted floating- point real-time value in its zeroth element, and a mnemonic describing the units being represented by the value in its first element.

roundToDecimals

public static java.lang.String roundToDecimals(double time,
                                               int scale)
Helper method that rounds a double value to a particular decimal scale

Parameters:
time - The value to scale
scale - The number of decimal places to round to.
Returns:
A String representing the formatted version of the specified value at the specified scale.

formatTime

public static java.lang.String formatTime(double ms_time)
Formats to a String the specified time value in milliseconds. Resulting String output contains a scaled value along with the mnemonic for the units represented by the value.

Parameters:
ms_time - The number of milliseconds to format.
Returns:
A string containing the formatted output.

formatTime

public static java.lang.String formatTime(double ms_time,
                                          int scale)
Formats to a String the specified time value in milliseconds. Resulting String output contains a scaled value along with the mnemonic for the units represented by the value.

Parameters:
ms_time - The number of milliseconds to format.
scale - The number of decimal places to round to.
Returns:
A string containing the formatted output.

splitFormatTime

public static java.lang.String[] splitFormatTime(double ms_time)
Formats a String that represents the real time value represented by the number of milliseconds specified. It separates the result into two Strings returned in a two element array of Strings, the zeroth element being the value, the first element being a mnemonic describing the units being represented by the value.

Parameters:
ms_time - The number of milliseconds to format.
Returns:
Two element array of type String containing a formatted floating- point real-time value in its zeroth element, and a mnemonic describing the units being represented by the value in its first element.

splitFormatTime

public static java.lang.String[] splitFormatTime(double ms_time,
                                                 int scale)
Formats a String that represents the real time value represented by the number of machine cycles passed in. It uses the specified time base for its calculations. It separates the result into two Strings returned in a two element array of Strings, the zeroth element being the value, the first element being a mnemonic describing the units being represented by the value.

Parameters:
ms_time - The number of milliseconds to format.
scale - The number of decimal places to round to.
Returns:
Two element array of type String containing a formatted floating- point real-time value in its zeroth element, and a mnemonic describing the units being represented by the value in its first element.