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