java - Running caliper from eclipse in maven's test scope -
i have java project in eclipse, junit tests in src/test
directory. i've added class tests caliper microbenchmarks, , i'd able run these tests within eclipse.
as caliper code test code, i've added caliper dependency in maven in test
scope. makes show in classpath when run junit tests, can't see way run arbitrary class test dependencies in classpath. tried doing adding new run configuration java application, thinking launch calipermain
right class parameter, caliper jar not on classpath , can't see how add it.
i don't want move benchmark code , dependency main
scope, it's test code! seems overkill move separate project.
you should able maven exec plugin. project, opted make benchmark profile can run maven command mvn compile -p benchmarks
.
to configure this, can add along lines of following pom.xml
, specifying scope of classpath test using <classpathscope>
tag:
<profiles> <profile> <id>benchmarks</id> <build> <plugins> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>exec-maven-plugin</artifactid> <version>1.2.1</version> <executions> <execution> <id>caliper</id> <phase>compile</phase> <goals> <goal>java</goal> </goals> <configuration> <classpathscope>test</classpathscope> <mainclass>com.google.caliper.runner.calipermain</mainclass> <commandlineargs>com.stackoverflow.bencharkclass,com.stackoverflow.anotherbenchmark</commandlineargs> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>
alternatively, if you'd specify lot of options caliper, easier use <arguments>
tags:
<executions> <execution> <id>caliper</id> <phase>compile</phase> <goals> <goal>java</goal> </goals> <configuration> <classpathscope>test</classpathscope> <mainclass>com.google.caliper.runner.calipermain</mainclass> <arguments> <argument>com.stackoverflow.bencharkclass</argument> <argument>--instrument</argument> <argument>runtime</argument> <argument>-cinstrument.allocation.options.trackallocations=false</argument> </arguments> </configuration> </execution> </executions>
more configuration options (like -cinstrument.allocation.options.trackallocations
above) can found here , more runtime options (like --instrument
above) can found here.
then, if using eclipse m2 maven plugin, can right-click on project folder , select run as... -> maven build...
, enter clean install
in goals
input box , benchmarks
in profiles
input box , click run
, should see output in eclipse console.
it's important note used local snapshot build of caliper checking out source using git clone https://code.google.com/p/caliper/
, recommended @ time of post in order take advantage of latest api.
Comments
Post a Comment