Java Code Examples for org.apache.commons.math3.stat.descriptive.StatisticalSummary#getSum()
The following examples show how to use
org.apache.commons.math3.stat.descriptive.StatisticalSummary#getSum() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ @SuppressWarnings("boxing") public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
Example 2
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
Example 3
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
Example 4
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ @SuppressWarnings("boxing") public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
Example 5
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
Example 6
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
Example 7
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ @SuppressWarnings("boxing") public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
Example 8
Source File: PerfTestUtils.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Timing and report (to standard output) the average time and standard * deviation of a single call. * The timing is performed by calling the * {@link #time(int,int,boolean,Callable[]) time} method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that * number of repeats of the code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When * set to {@code true}, the test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the * average times (in milliseconds) taken by a single call to the * {@code call} method (i.e. the time taken by each timed block divided * by {@code repeatChunk}). */ @SuppressWarnings("boxing") public static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, RunTest ... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println(String.format(cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println(String.format(format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }