Package org.apache.commons.math.stat.descriptive

Examples of org.apache.commons.math.stat.descriptive.DescriptiveStatistics


    private long begin;

    @Override
    public void executionStarted(String className, String testName) throws Exception {
        statistics = new DescriptiveStatistics();
    }
View Full Code Here


    int warmuptime = performanceAnnotation.warmuptime();
    int runtime = performanceAnnotation.runtime();
    int warmupinvocations = performanceAnnotation.warmupinvocations();
    int runinvocations = performanceAnnotation.runinvocations();

    DescriptiveStatistics statistics = new DescriptiveStatistics();

    if (warmupinvocations != 0) {
      // Run the number of invocation specified in the annotation
      // for warming up the system
      for (int invocationIndex = 0; invocationIndex < warmupinvocations; invocationIndex++) {

        recursiveCallSpecificMethod(this.target.getClass(), this.target, BeforeMethodInvocation.class);

        // TODO: implement the method to run a before a specific test
        // method
        // recursiveCallSpecificMethod(this.target.getClass(),
        // this.target, BeforeSpecificTest.class);

        response = super.invokeExplosively(this.target, params);

        // TODO: implement the method to run a after a specific test
        // method
        // recursiveCallSpecificMethod(this.target.getClass(),
        // this.target, AfterSpecificTest.class);

        recursiveCallSpecificMethod(this.target.getClass(),
            this.target, AfterMethodInvocation.class);
      }
    } else {
      // Run a few iterations to warm up the system
      long warmupEnd = System.currentTimeMillis() + warmuptime * 1000;
      while (System.currentTimeMillis() < warmupEnd) {
        recursiveCallSpecificMethod(this.target.getClass(),
            this.target, BeforeMethodInvocation.class);

        // TODO: implement the method to run a before a specific test
        // method
        // recursiveCallSpecificMethod(this.target.getClass(),
        // this.target, BeforeSpecificTest.class);

        response = super.invokeExplosively(this.target, params);

        // recursiveCallSpecificMethod(this.target.getClass(),
        // this.target, AfterSpecificTest.class);
        // TODO: implement the method to run a after a specific test
        // method

        recursiveCallSpecificMethod(this.target.getClass(),
            this.target, AfterMethodInvocation.class);
      }
    }

    // System.out.println("Warmup ended - test :" +
    // testMethodToInvoke.getName());
    if (runinvocations != 0) {
      // Run the specified number of iterations and capture the execution
      // times
      for (int invocationIndex = 0; invocationIndex < runinvocations; invocationIndex++) {

        response = this.invokeTimedTestMethod(testMethodToInvoke,
            statistics, params);
      }
    } else {
      // Run test iterations and capture the execution times
      long runtimeEnd = System.currentTimeMillis() + runtime * 1000;

      while (System.currentTimeMillis() < runtimeEnd) {

        response = this.invokeTimedTestMethod(testMethodToInvoke,
            statistics, params);

      }
    }

    if (statistics.getN() > 0) {
        ReportLogger.writeReport(this.performanceSuiteState.testSuiteName, testCaseName, className, getMethod().getName(),
                    statistics, ReportLogger.ReportType.TXT, reportLevel);
    }

    // In case of a PerformanceSuite we need to run the methods annotated
View Full Code Here

    this.results = results;
    this.runs = runs;
    this.times = compTimes;
    this.instance = instance;
    this.vehicles = vehicles;
    this.statsResults = new DescriptiveStatistics(results);
    this.statsTimes = new DescriptiveStatistics(times);
    this.statsVehicles = new DescriptiveStatistics(vehicles);
  }
View Full Code Here

        this.gets.clear();
      }
      super.testTakedown();
      if (opts.reportLatency) {
        Arrays.sort(times);
        DescriptiveStatistics ds = new DescriptiveStatistics();
        for (double t : times) {
          ds.addValue(t);
        }
        LOG.info("randomRead latency log (ms), on " + times.length + " measures");
        LOG.info("99.9999% = " + ds.getPercentile(99.9999d));
        LOG.info(" 99.999% = " + ds.getPercentile(99.999d));
        LOG.info("  99.99% = " + ds.getPercentile(99.99d));
        LOG.info("   99.9% = " + ds.getPercentile(99.9d));
        LOG.info("     99% = " + ds.getPercentile(99d));
        LOG.info("     95% = " + ds.getPercentile(95d));
        LOG.info("     90% = " + ds.getPercentile(90d));
        LOG.info("     80% = " + ds.getPercentile(80d));
        LOG.info("Standard Deviation = " + ds.getStandardDeviation());
        LOG.info("Mean = " + ds.getMean());
      }
    }
View Full Code Here

     * Test DescriptiveStatistics - implementations that store full array of
     * values and execute multi-pass algorithms
     */
    public void testDescriptiveStatistics() throws Exception {

        DescriptiveStatistics u = new DescriptiveStatistics();

        loadStats("data/PiDigits.txt", u);
        assertEquals("PiDigits: std", std, u.getStandardDeviation(), 1E-14);
        assertEquals("PiDigits: mean", mean, u.getMean(), 1E-14);

        loadStats("data/Mavro.txt", u);
        assertEquals("Mavro: std", std, u.getStandardDeviation(), 1E-14);
        assertEquals("Mavro: mean", mean, u.getMean(), 1E-14);

        loadStats("data/Michelso.txt", u);
        assertEquals("Michelso: std", std, u.getStandardDeviation(), 1E-14);
        assertEquals("Michelso: mean", mean, u.getMean(), 1E-14);

        loadStats("data/NumAcc1.txt", u);
        assertEquals("NumAcc1: std", std, u.getStandardDeviation(), 1E-14);
        assertEquals("NumAcc1: mean", mean, u.getMean(), 1E-14);

        loadStats("data/NumAcc2.txt", u);
        assertEquals("NumAcc2: std", std, u.getStandardDeviation(), 1E-14);
        assertEquals("NumAcc2: mean", mean, u.getMean(), 1E-14);
    }
View Full Code Here

     * @param file
     * @param statistical summary
     */
    private void loadStats(String resource, Object u) throws Exception {

        DescriptiveStatistics d = null;
        SummaryStatistics s = null;
        if (u instanceof DescriptiveStatistics) {
            d = (DescriptiveStatistics) u;
        } else {
            s = (SummaryStatistics) u;
        }
        u.getClass().getDeclaredMethod(
                "clear", new Class[]{}).invoke(u, new Object[]{});
        mean = Double.NaN;
        std = Double.NaN;

        BufferedReader in =
            new BufferedReader(
                    new InputStreamReader(
                            CertifiedDataTest.class.getResourceAsStream(resource)));

        String line = null;

        for (int j = 0; j < 60; j++) {
            line = in.readLine();
            if (j == 40) {
                mean =
                    Double.parseDouble(
                            line.substring(line.lastIndexOf(":") + 1).trim());
            }
            if (j == 41) {
                std =
                    Double.parseDouble(
                            line.substring(line.lastIndexOf(":") + 1).trim());
            }
        }

        line = in.readLine();

        while (line != null) {
            if (d != null) {
                d.addValue(Double.parseDouble(line.trim()));
            else {
                s.addValue(Double.parseDouble(line.trim()));
            }
            line = in.readLine();
        }
View Full Code Here

    private Map<String, Double> certifiedValues;

    @Override
    protected void setUp() throws Exception {
        descriptives = new DescriptiveStatistics();
        summaries = new SummaryStatistics();
        certifiedValues = new HashMap<String, Double>();

        loadData();
    }
View Full Code Here

                // Create the repository
                RepositoryImpl repository = createRepository(dir, xml);
                try {
                    // Run the test
                    DescriptiveStatistics statistics = runTest(test, repository);
                    if (statistics.getN() > 0) {
                        writeReport(test.toString(), name, statistics);
                    }
                } finally {
                    repository.shutdown();
                }
View Full Code Here

    }

    private DescriptiveStatistics runTest(
            AbstractTest test, Repository repository)
            throws Exception {
        DescriptiveStatistics statistics = new DescriptiveStatistics();

        test.setUp(repository, credentials);
        try {
            // Run a few iterations to warm up the system
            long warmupEnd = System.currentTimeMillis() + warmup * 1000;
            while (System.currentTimeMillis() < warmupEnd) {
                test.execute();
            }

            // Run test iterations, and capture the execution times
            long runtimeEnd = System.currentTimeMillis() + runtime * 1000;
            while (System.currentTimeMillis() < runtimeEnd) {
                statistics.addValue(test.execute());
            }
        } finally {
            test.tearDown();
        }

View Full Code Here

        for (RepositoryFixture fixture : fixtures) {
            try {
                Repository[] cluster = fixture.setUpCluster(1);
                try {
                    // Run the test
                    DescriptiveStatistics statistics = runTest(cluster[0]);
                    if (statistics.getN() > 0) {
                        System.out.format(
                                "%-28.28s  %6.0f  %6.0f  %6.0f  %6.0f  %6.0f  %6d%n",
                                fixture.toString(),
                                statistics.getMin(),
                                statistics.getPercentile(10.0),
                                statistics.getPercentile(50.0),
                                statistics.getPercentile(90.0),
                                statistics.getMax(),
                                statistics.getN());
                    }
                } finally {
                    fixture.tearDownCluster();
                }
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.commons.math.stat.descriptive.DescriptiveStatistics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.