|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsuramadu.util.time.Time
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 |
public static final java.lang.String TIME_MIN
public static final java.lang.String TIME_S
public static final java.lang.String TIME_MS
public static final java.lang.String TIME_US
public static final java.lang.String TIME_NS
public static final java.lang.String NATIVE_LIBRARY_NAME
public static final long cps
Constructor Detail |
public Time()
Method Detail |
public static long getCycles()
public static long getCPS(int bounds, int loops, int tolerace, int toleranceRetries, java.lang.String output)
public static void getTime(long[] timeArray)
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.public static long avgPeriod(int[] intArray, int offset)
intArray
- array of times to be convertedoffset
- begin calculations from offset position in intArray
Collection
public static long avgPeriod(long[] longArray, int offset)
longArray
- array of times to be convertedoffset
- begin calculations from offset position in longArray
Collection
public static int[] jitter(int[] intArray)
intArray
- array of times to be converted
Collection
public static int[] jitter(long period, int[] intArray)
period
- period from which to perform jitter calculationsintArray
- array of times to be converted
Collection
public static long[] jitter(long[] longArray)
longArray
- array of times to be converted
Collection
public static long[] jitter(long period, long[] longArray)
period
- period from which to perform jitter calculationslongArray
- array of times to be converted
Collection
public static int[] jitter(int[] intArray, int offset)
intArray
- array of times to be convertedoffset
- begin calculations from offset position in longArray
Collection
public static int[] jitter(long period, int[] intArray, int offset)
period
- period from which to perform jitter calculationsintArray
- array of times to be convertedoffset
- begin calculations from offset position in intArray
Collection
public static long[] jitter(long[] longArray, int offset)
longArray
- array of times to be convertedoffset
- begin calculations from offset position in longArray
Collection
public static long[] jitter(long period, long[] longArray, int offset)
period
- period from which to perform jitter calculationslongArray
- array of times to be convertedoffset
- begin calculations from offset position in longArray
Collection
public static double[] minFromCycles(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double[] minFromCycles(long[] cycles, long frequency)
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.
public static long[] minFromCyclesL(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static long[] minFromCyclesL(long[] cycles, long frequency)
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.
public static double minFromCycles(long cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double minFromCycles(long cycles, long frequency)
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.
public static double[] sFromCycles(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double[] sFromCycles(long[] cycles, long frequency)
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.
public static long[] sFromCyclesL(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static long[] sFromCyclesL(long[] cycles, long frequency)
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.
public static double sFromCycles(long cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double sFromCycles(long cycles, long frequency)
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.
public static double[] msFromCycles(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double[] msFromCycles(long[] cycles, long frequency)
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.
public static long[] msFromCyclesL(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static long[] msFromCyclesL(long[] cycles, long frequency)
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.
public static double msFromCycles(long cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double msFromCycles(long cycles, long frequency)
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.
public static double[] usFromCycles(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double[] usFromCycles(long[] cycles, long frequency)
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.
public static long[] usFromCyclesL(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static long[] usFromCyclesL(long[] cycles, long frequency)
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.
public static double usFromCycles(long cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double usFromCycles(long cycles, long frequency)
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.
public static double[] nsFromCycles(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double[] nsFromCycles(long[] cycles, long frequency)
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.
public static long[] nsFromCyclesL(long[] cycles)
cycles
- The number of machine cycles to use for the conversion.
public static long[] nsFromCyclesL(long[] cycles, long frequency)
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.
public static double nsFromCycles(long cycles)
cycles
- The number of machine cycles to use for the conversion.
public static double nsFromCycles(long cycles, long frequency)
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.
public static long cyclesFromMin(long minutes)
minutes
- The number of minutes to use for the conversion.
public static long cyclesFromMin(long minutes, long frequency)
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.
public static long cyclesFromS(long seconds)
seconds
- The number of seconds to use for the conversion.
public static long cyclesFromS(long seconds, long frequency)
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.
public static long cyclesFromMs(long ms)
ms
- The number of milliseconds to use for the conversion.
public static long cyclesFromMs(long ms, long frequency)
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.
public static long cyclesFromUs(long us)
us
- The number of microseconds to use for the conversion.
public static long cyclesFromUs(long us, long frequency)
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.
public static long cyclesFromNs(long ns)
ns
- The number of nanoseconds to use for the conversion.
public static long cyclesFromNs(long ns, long frequency)
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.
public static java.lang.String timeFromCycles(long cycles)
cycles
- The number of machine cycles to use for the conversion.
public static java.lang.String timeFromCycles(long cycles, long frequency)
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.
public static java.lang.String timeFromCycles(long cycles, int scale)
cycles
- The number of machine cycles to use for the conversion.scale
- the number of decimal places to which to round the result.
public static java.lang.String timeFromCycles(long cycles, long frequency, int scale)
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.
public static java.lang.String[] splitTimeFromCycles(long cycles)
cycles
- The number of machine cycles to use for the conversion.
public static java.lang.String[] splitTimeFromCycles(long cycles, long frequency)
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.
public static java.lang.String[] splitTimeFromCycles(long cycles, int scale)
cycles
- The number of machine cycles to use for the conversion.scale
- the number of decimal places to which to round the result.
public static java.lang.String[] splitTimeFromCycles(long cycles, long frequency, int scale)
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.
public static java.lang.String roundToDecimals(double time, int scale)
time
- The value to scalescale
- The number of decimal places to round to.
public static java.lang.String formatTime(double ms_time)
ms_time
- The number of milliseconds to format.
public static java.lang.String formatTime(double ms_time, int scale)
ms_time
- The number of milliseconds to format.scale
- The number of decimal places to round to.
public static java.lang.String[] splitFormatTime(double ms_time)
ms_time
- The number of milliseconds to format.
public static java.lang.String[] splitFormatTime(double ms_time, int scale)
ms_time
- The number of milliseconds to format.scale
- The number of decimal places to round to.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |