|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.qpid.junit.extensions.util.MathUtils
public class MathUtils
Mathematical support methods for the toolkit. Caculating averages, variances, min/max for test latencies and generating linear/exponential sequences for test size/concurrency ramping up.
The sequence specifications are of the form [lowest(, ...)(, highest)](,sample=s)(,exp), where round brackets enclose optional values. Using this pattern form it is possible to specify a single value, a range of values divided into s samples, a range of values divided into s samples but distributed exponentially, or a fixed set of samples. The duration arguments are of the form (dD)(hH)(mM)(sS), where round brackets enclose optional values. At least one of the optional values must be present.Responsibilities | Collaborations |
---|---|
Generate a sequene of integers from a sequence specification. | |
Parse an encoded duration into milliseconds. |
Field Summary | |
---|---|
static Pattern |
DURATION_PATTERN
The regular expression that matches the duration expression. |
static String |
DURATION_REGEXP
The duration definition matching regular expression. |
static Pattern |
NAME_VALUE_PATTERN
The regular expression that matches name=value pairs and variations. |
static String |
NAME_VALUE_REGEXP
For matching name=value pairs. |
static String |
NAME_VALUE_SEQUENCE_REGEXP
For matching name=[n: ... |
static String |
NAME_VALUE_VARIATION_REGEXP
For matching name=[value1: value2: ...] variations. |
static String |
SEQUENCE_REGEXP
The sequence defintion matching regular expression. |
Constructor Summary | |
---|---|
MathUtils()
|
Method Summary | |
---|---|
static int[] |
generateExpSequence(int start,
int end,
int steps)
Given a start and end and a number of steps this method generates a sequence of expontentially spaced integer values, starting at the start (inclusive) and finishing at the end (inclusive) with the specified number of values in the sequence. |
static int[] |
generateSequence(int start,
int end,
int steps)
Given a start and end and a number of steps this method generates a sequence of evenly spaced integer values, starting at the start (inclusive) and finishing at the end (inclusive) with the specified number of values in the sequence. |
static void |
main(String[] args)
Runs a quick test of the sequence generation methods to confirm that they work as expected. |
static int |
maxInArray(int[] values)
Returns the maximum value in an array of integers. |
static long |
parseDuration(String duration)
Parses a duration defined as a string, giving a duration in days, hours, minutes and seconds into a number of milliseconds equal to that duration. |
static int[] |
parseSequence(String sequenceDef)
Parses a string defintion of a sequence into an int array containing the sequence. |
static String |
printArray(int[] array)
Pretty prints an array of ints as a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String SEQUENCE_REGEXP
public static final String DURATION_REGEXP
public static final Pattern DURATION_PATTERN
public static final String NAME_VALUE_REGEXP
public static final String NAME_VALUE_VARIATION_REGEXP
public static final String NAME_VALUE_SEQUENCE_REGEXP
public static final Pattern NAME_VALUE_PATTERN
Constructor Detail |
---|
public MathUtils()
Method Detail |
---|
public static void main(String[] args)
args
- The command line parameters.public static int[] generateSequence(int start, int end, int steps)
start
- The sequence start.end
- The sequence end.steps
- The number of steps.
public static int[] generateExpSequence(int start, int end, int steps)
start
- The sequence start.end
- The sequence end.steps
- The number of steps.
public static int[] parseSequence(String sequenceDef)
sequenceDef
- The sequence definition.
public static long parseDuration(String duration)
duration
- The duration definition string.
public static String printArray(int[] array)
array
- The array to pretty print.
public static int maxInArray(int[] values)
values
- The array to find the amx in.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |