Package com.cyara.utilities
Class UtilsMath
java.lang.Object
com.cyara.utilities.UtilsMath
public class UtilsMath
extends java.lang.Object
Various methods used throughout the samples for calculations.
This is not an official Cyara product and is not officially supported. It is used for demonstration and training purposes. For assistance, contact chris.ryan@cyara.com
- Version:
- 1.0
- Author:
- Chris Ryan
-
Constructor Summary
Constructors Modifier Constructor Description private
UtilsMath()
Instantiates a new UtilsMath. -
Method Summary
Modifier and Type Method Description static int
distance(java.lang.String a, java.lang.String b)
Calculates the shortest character difference between two strings.static int
findMean(java.util.List<java.lang.Integer> responseTimes)
Finds the mean of a given sorted Integer ArrayListstatic int
findMeanDouble(java.util.List<java.lang.Double> responseTimes)
Finds the mean of a given sorted Integer ArrayListstatic int
findMedian(java.util.List<java.lang.Integer> responseTimes)
Finds the median of a given sorted Integer ArrayListstatic double
findMedianDouble(java.util.List<java.lang.Double> responseTimes)
Finds the median of a given sorted Integer ArrayListstatic int
findMode(java.util.List<java.lang.Integer> responseTimes)
Finds the mode of a given sorted Integer ArrayListstatic double
findModeDouble(java.util.List<java.lang.Double> responseTimes)
Finds the mode of a given sorted Integer ArrayListstatic int
findPercentile(java.util.List<java.lang.Integer> responseTimes, double percentile)
Finds the X percentile of a given sorted Integer ArrayListstatic double
findPercentileDouble(java.util.List<java.lang.Double> responseTimes, double percentile)
Finds the X percentile of a given sorted Integer ArrayListstatic double
generateCleanPercentages(double dividend, double divisor)
Calculates the percentage of divisor into the dividend.static int
getRandomNumber(int min, int max)
Randomly generates an integer within the range
-
Constructor Details
-
UtilsMath
private UtilsMath()Instantiates a new UtilsMath. Private to prevent instantiation.
-
-
Method Details
-
findMode
public static int findMode(java.util.List<java.lang.Integer> responseTimes)Finds the mode of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in milliseconds- Returns:
- The mode of the list
- Since:
- 1.0
-
findMedian
public static int findMedian(java.util.List<java.lang.Integer> responseTimes)Finds the median of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in milliseconds- Returns:
- The median of the list
- Since:
- 1.0
-
findMean
public static int findMean(java.util.List<java.lang.Integer> responseTimes)Finds the mean of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in milliseconds- Returns:
- The mean of the list
- Since:
- 1.0
-
findPercentile
public static int findPercentile(java.util.List<java.lang.Integer> responseTimes, double percentile)Finds the X percentile of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in millisecondspercentile
- The X percentile we want to grab- Returns:
- The mean of the list
- Since:
- 1.0
-
findModeDouble
public static double findModeDouble(java.util.List<java.lang.Double> responseTimes)Finds the mode of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in milliseconds- Returns:
- The mode of the list
- Since:
- 1.0
-
findMedianDouble
public static double findMedianDouble(java.util.List<java.lang.Double> responseTimes)Finds the median of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in milliseconds- Returns:
- The median of the list
- Since:
- 1.0
-
findMeanDouble
public static int findMeanDouble(java.util.List<java.lang.Double> responseTimes)Finds the mean of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in milliseconds- Returns:
- The mean of the list
- Since:
- 1.0
-
findPercentileDouble
public static double findPercentileDouble(java.util.List<java.lang.Double> responseTimes, double percentile)Finds the X percentile of a given sorted Integer ArrayList- Parameters:
responseTimes
- The sorted ArrayList containing the response times in millisecondspercentile
- The X percentile we want to grab- Returns:
- The mean of the list
- Since:
- 1.0
-
generateCleanPercentages
public static double generateCleanPercentages(double dividend, double divisor)Calculates the percentage of divisor into the dividend. Cleanly converts that into a percentage with 2 decimal places.- Parameters:
dividend
- The number to divide intodivisor
- The number that divides into the dividend- Returns:
- The cleaned percentage
- Since:
- 1.0
-
distance
public static int distance(java.lang.String a, java.lang.String b)Calculates the shortest character difference between two strings.- Parameters:
a
- The first string in the comparisonb
- The second string in the comparison- Returns:
- The character difference between the two strings
- Since:
- 1.0
-
getRandomNumber
public static int getRandomNumber(int min, int max)Randomly generates an integer within the range- Parameters:
min
- The smallest range of the random numbermax
- The largest range of the random number- Returns:
- The random number between min and max
- Since:
- 1.0
-