Search in sources :

Example 1 with AllLiteralAmplifiers

use of eu.stamp_project.dspot.amplifier.amplifiers.AllLiteralAmplifiers in project dspot by STAMP-project.

the class PerformanceTest method test.

@Ignore
@Test
public void test() throws Exception {
    /*
         * This test aims at measuring the time execution of multiple applications of Amplifiers.
         * This test is meant to be run manually
         */
    final int numberOfIteration = 3;
    final CtClass testClass = findClass("fr.inria.ampl.ToBeAmplifiedLiteralTest");
    final CtMethod originalTest = findMethod(testClass, "testInt");
    List<CtMethod> amplifiedTestMethod1 = Collections.singletonList(originalTest);
    List<CtMethod> amplifiedTestMethod2 = Collections.singletonList(originalTest);
    Amplifier testDataMutator = new FastLiteralAmplifier();
    testDataMutator.reset(testClass);
    Amplifier allLiteralAmplifiers = new AllLiteralAmplifiers();
    allLiteralAmplifiers.reset(testClass);
    long start = System.currentTimeMillis();
    for (int i = 0; i < numberOfIteration; i++) {
        amplifiedTestMethod1 = amplifiedTestMethod1.stream().flatMap(testMethod -> allLiteralAmplifiers.amplify(testMethod, 0)).collect(Collectors.toList());
        System.out.println("(" + i + ")Number of Amplification:" + amplifiedTestMethod1.size());
    }
    final long timeAllLiteral = System.currentTimeMillis() - start;
    System.out.println(timeAllLiteral + "ms");
    long start2 = System.currentTimeMillis();
    for (int i = 0; i < numberOfIteration; i++) {
        amplifiedTestMethod2 = amplifiedTestMethod2.stream().flatMap(testMethod -> testDataMutator.amplify(testMethod, 0)).collect(Collectors.toList());
        System.out.println("(" + i + ")Number of Amplification:" + amplifiedTestMethod2.size());
    }
    final long timeTestDataMutator = System.currentTimeMillis() - start2;
    System.out.println(timeTestDataMutator + "ms");
    assertTrue(timeTestDataMutator > timeAllLiteral);
    assertTrue(amplifiedTestMethod2.size() > amplifiedTestMethod1.size());
}
Also used : CtClass(spoon.reflect.declaration.CtClass) FastLiteralAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.FastLiteralAmplifier) FastLiteralAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.FastLiteralAmplifier) Amplifier(eu.stamp_project.dspot.amplifier.amplifiers.Amplifier) CtMethod(spoon.reflect.declaration.CtMethod) AllLiteralAmplifiers(eu.stamp_project.dspot.amplifier.amplifiers.AllLiteralAmplifiers) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AllLiteralAmplifiers (eu.stamp_project.dspot.amplifier.amplifiers.AllLiteralAmplifiers)1 Amplifier (eu.stamp_project.dspot.amplifier.amplifiers.Amplifier)1 FastLiteralAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.FastLiteralAmplifier)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 CtClass (spoon.reflect.declaration.CtClass)1 CtMethod (spoon.reflect.declaration.CtMethod)1