Search in sources :

Example 51 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project peass by DaGeRe.

the class CreateOverviewStatistics method main.

public static void main(final String[] args) throws JAXBException, JsonParseException, JsonMappingException, IOException {
    File dependencyFolder;
    final File repos;
    if (System.getenv(Constants.PEASS_REPOS) != null) {
        final String repofolder = System.getenv(Constants.PEASS_REPOS);
        repos = new File(repofolder);
        dependencyFolder = new File(repos, "dependencies-final");
    } else {
        throw new RuntimeException("Please define environment variable " + Constants.PEASS_REPOS);
    }
    final File propertyFolder = new File(repos, "properties/properties");
    final File changeFolder = new File(repos, "measurementdata/results");
    final File projectsFolder = new File("../../projekte");
    final DescriptiveStatistics[] stats = new DescriptiveStatistics[9];
    for (int i = 0; i < 9; i++) {
        stats[i] = new DescriptiveStatistics();
    }
    // "commons-imaging", "commons-io", "commons-numbers", "commons-pool", "commons-text", "httpcomponents-core", "k-9" }) {
    for (final String project : new String[] { "commons-csv", "commons-dbcp", "commons-fileupload", "commons-jcs", "commons-imaging", "commons-io", "commons-numbers", "commons-pool", "commons-text" }) {
        System.out.print(project + " & ");
        final int versions = GitUtils.getVersions(new File(projectsFolder, project));
        System.out.print(versions + " & ");
        stats[0].addValue(versions);
        final File executionFile = new File(dependencyFolder, ResultsFolders.TRACE_SELECTION_PREFIX + project + ".json");
        if (executionFile.exists()) {
            final ExecutionData changedTests = Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class);
            System.out.print(changedTests.getVersions().size() + " & ");
            stats[1].addValue(changedTests.getVersions().size());
            int tests = 0;
            for (final TestSet testSet : changedTests.getVersions().values()) {
                tests += testSet.getTests().size();
            }
            System.out.print(tests + " & ");
            stats[2].addValue(tests);
            int changes = 0;
            int sourceChanges = 0;
            int sourceTests = 0;
            final File potentialChangeFolder = new File(changeFolder, project);
            if (potentialChangeFolder.exists()) {
                final File changefile = new File(potentialChangeFolder, project + ".json");
                final ProjectChanges measuredChanges = Constants.OBJECTMAPPER.readValue(changefile, ProjectChanges.class);
                changes = measuredChanges.getChangeCount();
                final File changefileOnlysource = new File(propertyFolder, project + "/" + project + ".json");
                if (changefileOnlysource.exists()) {
                    final VersionChangeProperties measuredChangesOnlysource = Constants.OBJECTMAPPER.readValue(changefileOnlysource, VersionChangeProperties.class);
                    for (final ChangeProperties changesAll : measuredChangesOnlysource.getVersions().values()) {
                        for (final List<ChangeProperty> method : changesAll.getProperties().values()) {
                            for (final ChangeProperty nowMetho : method) {
                                if (nowMetho.isAffectsSource()) {
                                    sourceChanges++;
                                }
                            }
                        }
                    }
                // sourceChanges = measuredChangesOnlysource.getChangeCount();
                }
            }
            final File allTestProps = new File(propertyFolder, project + "/" + project + "_all.json");
            if (allTestProps.exists()) {
                final VersionChangeProperties properties = Constants.OBJECTMAPPER.readValue(allTestProps, VersionChangeProperties.class);
                sourceTests = properties.getSourceChanges();
            }
            // System.out.print(sourceTests + " & ");
            // stats[3].addValue(sourceTests);
            System.out.print(changes + " & ");
            stats[4].addValue(changes);
            System.out.print(sourceChanges + " & ");
            stats[5].addValue(sourceChanges);
            final File changeTestProperties = new File(propertyFolder, project + File.separator + project + ".json");
            if (changeTestProperties.exists()) {
                final VersionChangeProperties versionProperties = Constants.OBJECTMAPPER.readValue(changeTestProperties, VersionChangeProperties.class);
                final ProjectStatistics projectStatistics = new ProjectStatistics();
                versionProperties.executeProcessor(projectStatistics);
                System.out.print(new DecimalFormat("##.##").format(projectStatistics.affectedLines.getMean()) + " & ");
                stats[6].addValue(projectStatistics.affectedLines.getMean());
                System.out.print(new DecimalFormat("##.##").format(projectStatistics.calls.getMean()) + " & ");
                stats[7].addValue(projectStatistics.calls.getMean());
                final double durationMeanChange = projectStatistics.changes.getMean();
                System.out.print(new DecimalFormat("##.##").format(durationMeanChange) + " \\% ");
                stats[8].addValue(durationMeanChange);
            }
        }
        System.out.print(" \\\\");
        System.out.println();
    }
    System.out.println("\\hline");
    System.out.print(" & ");
    for (int i = 0; i < 9; i++) {
        System.out.print(new DecimalFormat("##.##").format(stats[i].getMean()) + " & ");
    }
    System.out.println();
    for (int i = 0; i < 9; i++) {
        System.out.print(stats[i].getSum() + " & ");
    }
    System.out.println();
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) DecimalFormat(java.text.DecimalFormat) ChangeProperty(de.dagere.peass.analysis.properties.ChangeProperty) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) ProjectChanges(de.dagere.peass.analysis.changes.ProjectChanges) ChangeProperties(de.dagere.peass.analysis.properties.ChangeProperties) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) File(java.io.File) TestSet(de.dagere.peass.dependency.analysis.data.TestSet)

Example 52 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project peass by DaGeRe.

the class MeanCoVData method printResult.

protected void printResult(final Result result, final File csvFile) throws IOException {
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(csvFile))) {
        DescriptiveStatistics statistics = new DescriptiveStatistics();
        for (final Value value : result.getFulldata().getValue()) {
            statistics.addValue(value.getValue());
            if (statistics.getValues().length == avgCount) {
                final double cov = statistics.getVariance() / statistics.getMean();
                writer.write(statistics.getMean() + " " + cov + "\n");
                // writer.write(FORMAT.format(statistics.getMean()) + ";" + FORMAT.format(cov) + "\n");
                statistics = new DescriptiveStatistics();
            }
        }
        writer.flush();
        // System.out.println("set title 'Mean and Coefficient of Variation for " + clazzname + "." + testcase.getName() + "'");
        // System.out.println("set y2range [0:5]");
        // System.out.println("set y2tics");
        // System.out.println("set datafile separator ';'");
        // System.out.println("plot '" + csvFile.getName() + "' u ($0*" + AVG_COUNT + "):1 title 'Mean', '" + csvFile.getName() + "' u ($0*" + AVG_COUNT + "):2 title 'CoV' axes
        // x1y2");
        System.out.print(", '" + csvFile.getName() + "' u ($0*" + avgCount + "):1 title 'Mean'");
    // System.out.println();
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) FileWriter(java.io.FileWriter) Value(de.dagere.kopeme.generated.Result.Fulldata.Value) BufferedWriter(java.io.BufferedWriter)

Example 53 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project peass by DaGeRe.

the class MeanCoVDataContinous method addValue.

protected void addValue(final int index, final double value, final List<DescriptiveStatistics> statistics) {
    DescriptiveStatistics meanSummary;
    if (statistics.size() <= index) {
        meanSummary = new DescriptiveStatistics();
        statistics.add(meanSummary);
    } else {
        meanSummary = statistics.get(index);
    }
    meanSummary.addValue(value);
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)

Example 54 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project peass by DaGeRe.

the class FindLowestIterationsRCA method getStatistic.

private DescriptiveStatistics getStatistic(final int iterations) {
    final DescriptiveStatistics stat = new DescriptiveStatistics();
    values.subList(0, iterations).forEach(value -> stat.addValue(value));
    return stat;
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)

Example 55 with DescriptiveStatistics

use of org.apache.commons.math3.stat.descriptive.DescriptiveStatistics in project peass by DaGeRe.

the class GetChangeClasses method main.

public static void main(final String[] args) throws JsonParseException, JsonMappingException, IOException {
    final File f = new File("results/merged.json");
    final ProjectChanges knowledge = Constants.OBJECTMAPPER.readValue(f, ProjectChanges.class);
    final Map<String, DescriptiveStatistics> clazzes = new HashMap<>();
    for (final Changes changes : knowledge.getVersionChanges().values()) {
        for (final List<Change> change : changes.getTestcaseChanges().values()) {
            for (final Change c : change) {
            // if (c.getCorrectness() != null && c.getCorrectness().equals("CORRECT")) {
            // for (String type : c.getType()) {
            // if (type.equals("FUNCTION") || type.equals("BUGFIX") || type.equals("FEATURE")) {
            // type = "FUNCTIONALITY";
            // }
            // if (type.equals("JUNIT")) {
            // type = "LIB";
            // }
            // DescriptiveStatistics clazz = clazzes.get(type);
            // if (clazz == null) {
            // clazz = new DescriptiveStatistics();
            // clazzes.put(type, clazz);
            // }
            // clazz.addValue(c.getChangePercent());
            // }
            // 
            // }
            }
        }
    }
    for (final Map.Entry<String, DescriptiveStatistics> clazz : clazzes.entrySet()) {
        System.out.println(clazz.getKey() + " " + clazz.getValue().getMean());
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) HashMap(java.util.HashMap) Change(de.dagere.peass.analysis.changes.Change) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)181 ArrayList (java.util.ArrayList)22 List (java.util.List)17 Test (org.testng.annotations.Test)15 Test (org.junit.Test)13 Test (org.junit.jupiter.api.Test)12 File (java.io.File)11 Plot (ij.gui.Plot)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 Rectangle (java.awt.Rectangle)8 TException (org.apache.thrift.TException)7 Result (de.dagere.kopeme.generated.Result)6 LinkedList (java.util.LinkedList)6 AbstractMagmaTest (org.obiba.magma.test.AbstractMagmaTest)6 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)6 PrecisionResultProcedure (uk.ac.sussex.gdsc.smlm.results.procedures.PrecisionResultProcedure)6 ImagePlus (ij.ImagePlus)5 PlotWindow (ij.gui.PlotWindow)5 ImageProcessor (ij.process.ImageProcessor)5 Map (java.util.Map)5