Arquillian Performance Extension
Java Shell Batchfile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github Introduces templates for GH issues and PRs Oct 26, 2016
.mvn/wrapper
api [maven-release-plugin] prepare for next development iteration Aug 10, 2011
impl
.gitignore Ignores gh-pages folder pointing to another branch Mar 17, 2017
.travis.yml Sets generated-doc to conditionally render README Mar 24, 2017
README.adoc Introduces conditional rendering in README Mar 24, 2017
mvnw
mvnw.cmd Adds mvn wrapper Mar 21, 2017
pom.xml Updates Arquillian Core (closes #5) Mar 15, 2017

README.adoc

Arquillian Performance Extension

Build Status

To read complete documentation visit http://arquillian.org/arquillian-extension-performance/

The performance extension for Arquillian is a simple way of checking that the code you want to test performs within the range you want it to. It can also automatically catch any performance regressions that might be added to your applications and as Arquillian itself, it is very easy to use.

1. Code example

// include other arquillian imports here...
import org.jboss.arquillian.performance.annotation.Performance;
import org.jboss.arquillian.performance.annotation.PerformanceTest;

@PerformanceTest(resultsThreshold=2)
@RunWith(Arquillian.class)
public class WorkHardCdiTestCase
{
   @Deployment
   public static JavaArchive createDeployment() {
       return ShrinkWrap.create(JavaArchive.class ,"test.jar")
               .addPackage( WorkHard.class.getPackage())
               .addAsManifestResource(
                       EmptyAsset.INSTANCE,
                       ArchivePaths.create("beans.xml"));
   }

   @Inject HardWorker worker;

   @Test
   @Performance(time=20)
   public void doHardWork() throws Exception
   {
      Assert.assertEquals(21, worker.workingHard(), 0d);
   }
}

As you can see the only two additions needed are @Performance and @PerformanceTest. They do different things and can be used separately or combined.

@Performance requires one argument, time (a double) which sets the required maximum time in milliseconds that the test is allowed to spend. If the test exceeds that time it will fail with an exception explaining the cause.

@PerformanceTest will cause every test run of that test to be saved and every new run will compare results with previous runs. If the new test run exceeds the previous runs with a defined threshold an exception will be thrown. The threshold can be set with the parameter resultsThreshold. It is by default set to 1d.

Note
How threshold is calculated: resultsThreshold * newTime < oldTime.

2. Maven setup example

The only extra dependency needed is to add arquillian-performance to your pom.xml. Take a look at the Getting started to see how you set up arquillian using maven.

<dependency>
   <groupId>org.jboss.arquillian.extension</groupId>
   <artifactId>arquillian-performance-impl</artifactId>
   <version>${arquillian.version}</version>
   <scope>test</scope>
</dependency>