Search in sources :

Example 1 with JmhTestTransformer

use of de.dagere.peass.dependency.jmh.JmhTestTransformer in project peass by DaGeRe.

the class JmhIterationTest method testVersionReading.

@Test
public void testVersionReading() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, JAXBException {
    FileUtils.copyDirectory(JmhTestConstants.BASIC_VERSION, TestConstants.CURRENT_FOLDER);
    MeasurementConfig measurementConfig = new MeasurementConfig(VMS);
    measurementConfig.setIterations(ITERATIONS);
    measurementConfig.setWarmup(WARMUP);
    measurementConfig.getExecutionConfig().setTestExecutor(WorkloadType.JMH.getTestExecutor());
    JmhTestTransformer transformer = new JmhTestTransformer(TestConstants.CURRENT_FOLDER, measurementConfig);
    PeassFolders folders = new PeassFolders(TestConstants.CURRENT_FOLDER);
    TestExecutor executor = ExecutorCreator.createExecutor(folders, transformer, new EnvironmentVariables());
    // File logFile = new File(folders.getLogFolder(), "test.txt");
    TestCase testcase = new TestCase("de.dagere.peass.ExampleBenchmark#testMethod");
    executor.prepareKoPeMeExecution(new File(folders.getMeasureLogFolder(), "compile.txt"));
    for (int i = 0; i < 3; i++) {
        executor.executeTest(testcase, folders.getMeasureLogFolder(), 100);
    }
    File clazzFolder = folders.findTempClazzFolder(testcase).get(0);
    Kopemedata data = XMLDataLoader.loadData(new File(clazzFolder, testcase.getMethod() + ".xml"));
    TestcaseType testcaseData = data.getTestcases().getTestcase().get(0);
    Assert.assertEquals("de.dagere.peass.ExampleBenchmark", data.getTestcases().getClazz());
    Assert.assertEquals("testMethod", testcaseData.getName());
    Assert.assertEquals(VMS, testcaseData.getDatacollector().get(0).getResult().size());
    List<Result> results = testcaseData.getDatacollector().get(0).getResult();
    Assert.assertEquals(ITERATIONS + WARMUP, results.get(0).getFulldata().getValue().size());
    for (Result result : results) {
        DescriptiveStatistics statistics = new DescriptiveStatistics();
        result.getFulldata().getValue().forEach(value -> statistics.addValue(value.getValue()));
        Assert.assertEquals(statistics.getMean(), result.getValue(), 0.01);
        Assert.assertEquals(statistics.getStandardDeviation(), result.getDeviation(), 0.01);
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) TestExecutor(de.dagere.peass.execution.utils.TestExecutor) DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) PeassFolders(de.dagere.peass.folders.PeassFolders) Result(de.dagere.kopeme.generated.Result) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) JmhTestTransformer(de.dagere.peass.dependency.jmh.JmhTestTransformer) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) TestcaseType(de.dagere.kopeme.generated.TestcaseType) Kopemedata(de.dagere.kopeme.generated.Kopemedata) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 2 with JmhTestTransformer

use of de.dagere.peass.dependency.jmh.JmhTestTransformer in project peass by DaGeRe.

the class JmhIterationTestMultiParam method testVersionReading.

@Test
public void testVersionReading() throws IOException, InterruptedException, XmlPullParserException, ParseException, ViewNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, JAXBException {
    FileUtils.copyDirectory(JmhTestConstants.MULTIPARAM_VERSION, TestConstants.CURRENT_FOLDER);
    MeasurementConfig measurementConfig = new MeasurementConfig(3);
    measurementConfig.setIterations(4);
    measurementConfig.setWarmup(2);
    JmhTestTransformer transformer = new JmhTestTransformer(TestConstants.CURRENT_FOLDER, measurementConfig);
    PeassFolders folders = new PeassFolders(TestConstants.CURRENT_FOLDER);
    TestExecutor executor = ExecutorCreator.createExecutor(folders, transformer, new EnvironmentVariables());
    // File logFile = new File(folders.getLogFolder(), "test.txt");
    TestCase testcase = new TestCase("de.dagere.peass.ExampleBenchmark#testMethod");
    executor.prepareKoPeMeExecution(new File(folders.getMeasureLogFolder(), "compile.txt"));
    executor.executeTest(testcase, folders.getMeasureLogFolder(), 100);
    File clazzFolder = folders.findTempClazzFolder(testcase).get(0);
    Kopemedata data = XMLDataLoader.loadData(new File(clazzFolder, testcase.getMethod() + ".xml"));
    TestcaseType testcaseData = data.getTestcases().getTestcase().get(0);
    Assert.assertEquals("de.dagere.peass.ExampleBenchmark", data.getTestcases().getClazz());
    Assert.assertEquals("testMethod", testcaseData.getName());
    Assert.assertEquals(6, testcaseData.getDatacollector().get(0).getResult().size());
    List<Result> results = testcaseData.getDatacollector().get(0).getResult();
    Assert.assertEquals(4, results.get(0).getFulldata().getValue().size());
    List<String> params = results.stream().map(result -> result.getParams().getParam().stream().map(param -> param.getKey() + "-" + param.getValue()).collect(Collectors.joining(" "))).collect(Collectors.toList());
    Assert.assertThat(params, IsIterableContaining.hasItems("parameter-val1", "parameter-val2"));
    for (Result result : results) {
        DescriptiveStatistics statistics = new DescriptiveStatistics();
        result.getFulldata().getValue().forEach(value -> statistics.addValue(value.getValue()));
        Assert.assertEquals(statistics.getMean(), result.getValue(), 0.01);
        Assert.assertEquals(statistics.getStandardDeviation(), result.getDeviation(), 0.01);
    }
}
Also used : MeasurementConfig(de.dagere.peass.config.MeasurementConfig) TestExecutor(de.dagere.peass.execution.utils.TestExecutor) BeforeEach(org.junit.jupiter.api.BeforeEach) ViewNotFoundException(de.dagere.peass.dependencyprocessors.ViewNotFoundException) PeassFolders(de.dagere.peass.folders.PeassFolders) TestConstants(de.dagere.peass.TestConstants) XMLDataLoader(de.dagere.kopeme.datastorage.XMLDataLoader) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ParseException(com.github.javaparser.ParseException) MeasurementConfig(de.dagere.peass.config.MeasurementConfig) TestUtil(de.dagere.peass.TestUtil) TestcaseType(de.dagere.kopeme.generated.TestcaseType) TestExecutor(de.dagere.peass.execution.utils.TestExecutor) Kopemedata(de.dagere.kopeme.generated.Kopemedata) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) JAXBException(javax.xml.bind.JAXBException) File(java.io.File) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.junit.jupiter.api.Test) List(java.util.List) IsIterableContaining(org.hamcrest.core.IsIterableContaining) DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) JmhTestTransformer(de.dagere.peass.dependency.jmh.JmhTestTransformer) Assert(org.junit.Assert) Result(de.dagere.kopeme.generated.Result) ExecutorCreator(de.dagere.peass.dependency.ExecutorCreator) DescriptiveStatistics(org.apache.commons.math3.stat.descriptive.DescriptiveStatistics) PeassFolders(de.dagere.peass.folders.PeassFolders) Result(de.dagere.kopeme.generated.Result) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) JmhTestTransformer(de.dagere.peass.dependency.jmh.JmhTestTransformer) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) TestcaseType(de.dagere.kopeme.generated.TestcaseType) Kopemedata(de.dagere.kopeme.generated.Kopemedata) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 3 with JmhTestTransformer

use of de.dagere.peass.dependency.jmh.JmhTestTransformer in project peass by DaGeRe.

the class JmhParallelExecutionTest method prepareThreads.

private void prepareThreads(final File[] testFolders, final JmhTestExecutor[] executors, final Thread[] threads, final MeasurementConfig measurementConfig) throws IOException, InterruptedException, XmlPullParserException {
    for (int i = 0; i < 2; i++) {
        testFolders[i] = new File(BASE_FOLDER, "jmh-" + i);
        FileUtils.copyDirectory(JmhTestConstants.BASIC_VERSION, testFolders[i]);
        PeassFolders folders = new PeassFolders(testFolders[i]);
        JmhTestTransformer transformer = new JmhTestTransformer(testFolders[i], measurementConfig);
        executors[i] = new JmhTestExecutor(folders, transformer, new EnvironmentVariables());
        executors[i].prepareKoPeMeExecution(new File(folders.getMeasureLogFolder(), "clean.txt"));
        final int j = i;
        threads[i] = new Thread(new Runnable() {

            @Override
            public void run() {
                File logFolder = new File(BASE_FOLDER, "" + j);
                logFolder.mkdirs();
                executors[j].executeTest(test, logFolder, 100);
            }
        });
    }
}
Also used : JmhTestExecutor(de.dagere.peass.dependency.jmh.JmhTestExecutor) EnvironmentVariables(de.dagere.peass.execution.utils.EnvironmentVariables) JmhTestTransformer(de.dagere.peass.dependency.jmh.JmhTestTransformer) File(java.io.File) PeassFolders(de.dagere.peass.folders.PeassFolders)

Example 4 with JmhTestTransformer

use of de.dagere.peass.dependency.jmh.JmhTestTransformer in project peass by DaGeRe.

the class TestBenchmarkDetection method testBenchmarkDetectionInnerClass.

@Test
public void testBenchmarkDetectionInnerClass() throws FileNotFoundException, IOException, XmlPullParserException {
    JmhTestTransformer jmhTransformer = new JmhTestTransformer(JmhTestConstants.INNER_CLASS_VERSION, JMH_CONFIG);
    ProjectModules modules = new ProjectModules(JmhTestConstants.INNER_CLASS_VERSION);
    TestSet tests = jmhTransformer.findModuleTests(new ModuleClassMapping(JmhTestConstants.INNER_CLASS_VERSION, modules, new ExecutionConfig()), null, modules);
    Assert.assertEquals(tests.getTests().size(), 1);
    TestCase test = tests.getTests().iterator().next();
    Assert.assertEquals("de.dagere.peass.ExampleBenchmark#testMethod", test.getExecutable());
}
Also used : JmhTestTransformer(de.dagere.peass.dependency.jmh.JmhTestTransformer) ProjectModules(de.dagere.peass.execution.utils.ProjectModules) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) ModuleClassMapping(de.dagere.peass.dependency.analysis.ModuleClassMapping) ExecutionConfig(de.dagere.peass.config.ExecutionConfig) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Example 5 with JmhTestTransformer

use of de.dagere.peass.dependency.jmh.JmhTestTransformer in project peass by DaGeRe.

the class TestBenchmarkChangeDetection method testBenchmarkDetection.

@Test
public void testBenchmarkDetection() throws FileNotFoundException, IOException, XmlPullParserException {
    JmhTestTransformer jmhTransformer = new JmhTestTransformer(JmhTestConstants.BASIC_VERSION, TestBenchmarkDetection.JMH_CONFIG);
    TestSet originalTests = new TestSet(new TestCase("de.dagere.peass.ExampleBenchmark", (String) null, ""));
    TestSet changedTests = jmhTransformer.buildTestMethodSet(originalTests, Arrays.asList(new File[] { JmhTestConstants.BASIC_VERSION }));
    Assert.assertEquals(changedTests.getTests().size(), 1);
    TestCase test = changedTests.getTests().iterator().next();
    Assert.assertEquals("de.dagere.peass.ExampleBenchmark#testMethod", test.getExecutable());
}
Also used : JmhTestTransformer(de.dagere.peass.dependency.jmh.JmhTestTransformer) TestCase(de.dagere.peass.dependency.analysis.data.TestCase) File(java.io.File) TestSet(de.dagere.peass.dependency.analysis.data.TestSet) Test(org.junit.jupiter.api.Test)

Aggregations

JmhTestTransformer (de.dagere.peass.dependency.jmh.JmhTestTransformer)7 TestCase (de.dagere.peass.dependency.analysis.data.TestCase)6 Test (org.junit.jupiter.api.Test)6 File (java.io.File)5 TestSet (de.dagere.peass.dependency.analysis.data.TestSet)4 ExecutionConfig (de.dagere.peass.config.ExecutionConfig)3 ModuleClassMapping (de.dagere.peass.dependency.analysis.ModuleClassMapping)3 EnvironmentVariables (de.dagere.peass.execution.utils.EnvironmentVariables)3 ProjectModules (de.dagere.peass.execution.utils.ProjectModules)3 PeassFolders (de.dagere.peass.folders.PeassFolders)3 Kopemedata (de.dagere.kopeme.generated.Kopemedata)2 Result (de.dagere.kopeme.generated.Result)2 TestcaseType (de.dagere.kopeme.generated.TestcaseType)2 MeasurementConfig (de.dagere.peass.config.MeasurementConfig)2 TestExecutor (de.dagere.peass.execution.utils.TestExecutor)2 DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)2 ParseException (com.github.javaparser.ParseException)1 XMLDataLoader (de.dagere.kopeme.datastorage.XMLDataLoader)1 TestConstants (de.dagere.peass.TestConstants)1 TestUtil (de.dagere.peass.TestUtil)1