public class TestTimes extends java.lang.Object implements TestTimesInterface
TestTimesInterface.MemoryUnits, TestTimesInterface.TimeUnits| Modifier and Type | Field and Description |
|---|---|
private static double |
BYTES_IN_KILOBYTE |
private static double |
BYTES_IN_MEGABYTE |
private int |
index |
private TestTimesInterface.MemoryUnits |
memoryUnits |
private long[] |
memoryUsages |
private static double |
NANO_SECONDS_IN_A_MICRO_SECOND |
private static double |
NANO_SECONDS_IN_A_MILLI_SECOND |
private static double |
NANO_SECONDS_IN_A_SECOND |
private java.lang.Runtime |
rt |
private long[] |
testTimes |
private TestTimesInterface.TimeUnits |
timeUnits |
| Constructor and Description |
|---|
TestTimes() |
| Modifier and Type | Method and Description |
|---|---|
void |
addTestTime(long runTime)
This method is used to add a test time and capture the current memory usage.
|
private double |
convertMemoryUsage(double memoryUsage) |
private double |
convertMemoryUsage(long memoryUsage) |
private double |
convertTestTime(double runTime) |
private double |
convertTestTime(long runTime) |
double |
getAverageMemoryUsage()
This method is used to obtain the average memory usage.
|
double |
getAverageTestTime()
This method is used to obtain the average test time.
|
double |
getLastMemoryUsage()
This method is used to retrieve the last memory usage.
|
double |
getLastTestTime()
This method is used to retrieve the last test time.
|
TestTimesInterface.MemoryUnits |
getMemoryUnits()
This method is used to obtain the current
TestTimesInterface.MemoryUnits configured for the RunTime
class. |
double[] |
getMemoryUsages()
This method returns an array of double values representing the last 10 memory usages
converted to the configured
TestTimesInterface.MemoryUnits. |
double[] |
getTestTimes()
This method returns an array of double values representing the last 10 test times
converted to the configured
TestTimesInterface.TimeUnits. |
TestTimesInterface.TimeUnits |
getTimeUnits()
This method is used to obtain the current
TestTimesInterface.TimeUnits configured for the RunTime
class. |
void |
resetTestTimes()
This method is used to reset all 10 linear search times to zero.
|
void |
setMemoryUnits(TestTimesInterface.MemoryUnits memoryUnits)
This method is used to configure the desired
TestTimesInterface.MemoryUnits. |
void |
setTimeUnits(TestTimesInterface.TimeUnits timeUnits)
This method is used to configure the desired
TestTimesInterface.TimeUnits. |
private TestTimesInterface.MemoryUnits memoryUnits
private TestTimesInterface.TimeUnits timeUnits
private static final double BYTES_IN_KILOBYTE
private static final double BYTES_IN_MEGABYTE
private static final double NANO_SECONDS_IN_A_SECOND
private static final double NANO_SECONDS_IN_A_MILLI_SECOND
private static final double NANO_SECONDS_IN_A_MICRO_SECOND
private java.lang.Runtime rt
private long[] testTimes
private long[] memoryUsages
private int index
private double convertTestTime(long runTime)
private double convertTestTime(double runTime)
private double convertMemoryUsage(long memoryUsage)
private double convertMemoryUsage(double memoryUsage)
public TestTimesInterface.TimeUnits getTimeUnits()
TestTimesInterfaceTestTimesInterface.TimeUnits configured for the RunTime
class. Please note that the default TimeUnits is NanoSecondsgetTimeUnits in interface TestTimesInterfaceTimeUnits.public void setTimeUnits(TestTimesInterface.TimeUnits timeUnits)
TestTimesInterfaceTestTimesInterface.TimeUnits.setTimeUnits in interface TestTimesInterfacetimeUnits - The desired TimeUnitspublic TestTimesInterface.MemoryUnits getMemoryUnits()
TestTimesInterfaceTestTimesInterface.MemoryUnits configured for the RunTime
class. Please note that the default MemoryUnits is BytesgetMemoryUnits in interface TestTimesInterfaceMemoryUnits.public void setMemoryUnits(TestTimesInterface.MemoryUnits memoryUnits)
TestTimesInterfaceTestTimesInterface.MemoryUnits.setMemoryUnits in interface TestTimesInterfacememoryUnits - The desired MemoryUnitspublic double getLastTestTime()
TestTimesInterfacegetLastTestTime in interface TestTimesInterfaceTestTimesInterface.TimeUnits,
or 0.public double getLastMemoryUsage()
TestTimesInterfacegetLastMemoryUsage in interface TestTimesInterfaceTestTimesInterface.MemoryUnits,
or 0.0.public double[] getTestTimes()
TestTimesInterfaceTestTimesInterface.TimeUnits. If less than 10 test times are available,
the remaining test times should be zero. If more than 10 test times have been added, the array
should contain the last 10 test times.getTestTimes in interface TestTimesInterfacepublic double[] getMemoryUsages()
TestTimesInterfaceTestTimesInterface.MemoryUnits.
If less than 10 memory usages are available, the remaining
memory usages should be zero. If more than 10 memory usages have been added, the array
should contain the last 10 memory usages.getMemoryUsages in interface TestTimesInterfacepublic void resetTestTimes()
TestTimesInterfaceresetTestTimes in interface TestTimesInterfacepublic void addTestTime(long runTime)
TestTimesInterfaceaddTestTime in interface TestTimesInterfacerunTime - a long value representing the test time in nanoseconds.public double getAverageTestTime()
TestTimesInterfacegetAverageTestTime in interface TestTimesInterfaceTestTimesInterface.TimeUnits or 0.public double getAverageMemoryUsage()
TestTimesInterfacegetAverageMemoryUsage in interface TestTimesInterfaceTestTimesInterface.MemoryUnits, or 0.0.