Search in sources :

Example 1 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class ExperimentSelector method selectForProject.

private void selectForProject(final File currentPropertyFile, final File currentChangeFile) throws IOException, JsonParseException, JsonMappingException, FileNotFoundException {
    final RepoFolders repoFolders = new RepoFolders();
    final VersionChangeProperties properties = Constants.OBJECTMAPPER.readValue(currentPropertyFile, VersionChangeProperties.class);
    final ProjectChanges changes;
    if (currentChangeFile != null && currentChangeFile.exists()) {
        changes = Constants.OBJECTMAPPER.readValue(currentChangeFile, ProjectChanges.class);
    } else {
        changes = null;
    }
    final String projectName = currentChangeFile != null ? currentChangeFile.getName().replace(".json", "") : currentPropertyFile.getParentFile().getName();
    final File fileSlurm = new File(repoFolders.getRCAScriptFolder(), "rca-slurm-" + projectName + ".sh");
    final File fileJava = new File(repoFolders.getRCAScriptFolder(), "rca-java-" + projectName + ".sh");
    final ExecutionData executionData = repoFolders.getExecutionData(projectName);
    final RunCommandWriter writerSlurm = new RunCommandWriterSlurm(new PrintStream(fileSlurm), "cause1", executionData, RunCommandWriterSlurm.EXECUTE_RCA);
    final RunCommandWriter writer = new RunCommandWriterRCA(new PrintStream(fileJava), "cause1", executionData);
    properties.executeProcessor((version, testcase, change, changeProperties) -> {
        all++;
    });
    if (changes != null) {
        changes.executeProcessor((version, testcase, change) -> {
            measurementAll++;
        });
    } else {
        printOnlyChanged = false;
    }
    writeExecutions(properties, changes, writerSlurm, writer);
    System.out.println("All: " + executionData.getAllExecutions());
    System.out.println("All: " + all + " No testchange: " + noTestchange + " Measurement change: " + measurementChange + " All: " + measurementAll);
}
Also used : PrintStream(java.io.PrintStream) ProjectChanges(de.dagere.peass.analysis.changes.ProjectChanges) RunCommandWriterSlurm(de.dagere.peass.measurement.utils.RunCommandWriterSlurm) RunCommandWriterRCA(de.dagere.peass.measurement.utils.RunCommandWriterRCA) VersionChangeProperties(de.dagere.peass.analysis.properties.VersionChangeProperties) RunCommandWriter(de.dagere.peass.measurement.utils.RunCommandWriter) File(java.io.File) RepoFolders(de.dagere.peass.analysis.all.RepoFolders) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 2 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class ReadProperties method call.

@Override
public Void call() throws Exception {
    final RepoFolders folders = new RepoFolders();
    final String projectName = projectFolder.getName();
    SelectedTests selectedTests = VersionSorter.getSelectedTests(staticSelectionFile, executionFile, folders.getDependencyFile(projectName));
    if (!projectFolder.exists()) {
        GitUtils.downloadProject(selectedTests.getUrl(), projectFolder);
    }
    System.out.println("Read all: " + ReadAllProperties.readAll);
    if (ReadAllProperties.readAll) {
        final ExecutionData changedTests = executionFile != null ? Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class) : folders.getExecutionData(projectName);
        final File resultFile = new File("results" + File.separator + projectName + File.separator + "properties_alltests.json");
        out = resultFile;
        ResultsFolders resultsFolders = new ResultsFolders(out, projectName);
        final PropertyReader reader = new PropertyReader(resultsFolders, projectFolder, changedTests, new ExecutionConfig());
        reader.readAllTestsProperties();
    } else {
        final File changefile;
        if (this.changefile != null) {
            changefile = this.changefile;
        } else {
            changefile = folders.getChangeFile(projectName);
        }
        if (out == null) {
            out = folders.getProjectPropertyFile(projectName);
            if (!out.getParentFile().exists()) {
                out.getParentFile().mkdirs();
            }
        }
        if (!changefile.exists()) {
            LOG.error("Changefile {} needs to exist.", changefile);
            System.exit(1);
        }
        if (!viewfolder.exists()) {
            LOG.error("ViewFolder {} needs to exist.", viewfolder);
            System.exit(1);
        }
        StaticTestSelection dependencies = Constants.OBJECTMAPPER.readValue(staticSelectionFile, StaticTestSelection.class);
        readChangeProperties(changefile, projectFolder, viewfolder, new ExecutionData(dependencies));
    }
    return null;
}
Also used : SelectedTests(de.dagere.peass.dependency.persistence.SelectedTests) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) ResultsFolders(de.dagere.peass.folders.ResultsFolders) PropertyReader(de.dagere.peass.analysis.properties.PropertyReader) File(java.io.File) RepoFolders(de.dagere.peass.analysis.all.RepoFolders) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData) StaticTestSelection(de.dagere.peass.dependency.persistence.StaticTestSelection)

Example 3 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class RepoFolders method getExecutionData.

public ExecutionData getExecutionData(final String project) throws JsonParseException, JsonMappingException, IOException {
    final File executionFile = new File(dependencyFolder, ResultsFolders.TRACE_SELECTION_PREFIX + project + ".json");
    final ExecutionData changedTests = Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class);
    return changedTests;
}
Also used : File(java.io.File) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Example 4 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData 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 5 with ExecutionData

use of de.dagere.peass.dependency.persistence.ExecutionData in project peass by DaGeRe.

the class FindChangeExecutions method findProjectExecutions.

public static void findProjectExecutions(final File reexecuteFolder, final String project, final File projectChangeFile, final File executionFile) throws FileNotFoundException, JAXBException, IOException, JsonParseException, JsonMappingException {
    System.out.println("Reading: " + project);
    final File reexecuteProject = new File(reexecuteFolder, "reexecute-change-" + project + ".sh");
    final PrintStream goal = new PrintStream(new FileOutputStream(reexecuteProject));
    final ExecutionData executions = Constants.OBJECTMAPPER.readValue(executionFile, ExecutionData.class);
    // RunCommandWriter writer = new RunCommandWriterSlurm(goal, NAME, dependencies);
    final RunCommandWriter writer = new RunCommandWriterRCA(goal, NAME, executions);
    writer.setNice(1000);
    writeExecutions(projectChangeFile, executions, writer);
}
Also used : PrintStream(java.io.PrintStream) FileOutputStream(java.io.FileOutputStream) RunCommandWriterRCA(de.dagere.peass.measurement.utils.RunCommandWriterRCA) RunCommandWriter(de.dagere.peass.measurement.utils.RunCommandWriter) File(java.io.File) ExecutionData(de.dagere.peass.dependency.persistence.ExecutionData)

Aggregations

ExecutionData (de.dagere.peass.dependency.persistence.ExecutionData)42 File (java.io.File)25 StaticTestSelection (de.dagere.peass.dependency.persistence.StaticTestSelection)12 Test (org.junit.jupiter.api.Test)10 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)8 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)8 ResultsFolders (de.dagere.peass.folders.ResultsFolders)7 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)6 PeassFolders (de.dagere.peass.folders.PeassFolders)5 PrintStream (java.io.PrintStream)5 RepoFolders (de.dagere.peass.analysis.all.RepoFolders)4 ProjectChanges (de.dagere.peass.analysis.changes.ProjectChanges)4 PropertyReader (de.dagere.peass.analysis.properties.PropertyReader)4 KiekerConfig (de.dagere.peass.config.KiekerConfig)4 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)4 ChangeReader (de.dagere.peass.analysis.changes.ChangeReader)3 VersionKeeper (de.dagere.peass.dependency.reader.VersionKeeper)3 LinkedList (java.util.LinkedList)3 Change (de.dagere.peass.analysis.changes.Change)2 VersionChangeProperties (de.dagere.peass.analysis.properties.VersionChangeProperties)2