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();
}
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();
}
}
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);
}
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;
}
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());
}
}
Aggregations