Benchmarking Parameterized Tests

90 views
Skip to first unread message

amit shah

unread,
Jun 18, 2013, 9:14:01 AM6/18/13
to junit-be...@googlegroups.com
I am trying to benchmark the test executions of a parameterized junit test class. Below is the sample code

@BenchmarkOptions(benchmarkRounds = 5, warmupRounds = 2)
@BenchmarkMethodChart(filePrefix = "benchmarkTest-benchmarks")
@RunWith(Parameterized.class)
public class BenchmarkTest extends AbstractBenchmark {

    private String fileName;
    private Logger logger = LoggerFactory.getLogger(BenchmarkTest.class);

    public BenchmarkTest(String fileName) {
        this.fileName = fileName;
    }

    @Parameterized.Parameters
    public static Collection<Object[]> data() {
        Object[][] data = new Object[][] { { "F1" }, { "F2" }, { "F3" } };
        return Arrays.asList(data);
    }

    @Test
    public void testNothing() {
        logger.info("Executing for file name : {}", fileName);
        long startTime = System.currentTimeMillis();
        while (System.currentTimeMillis() - startTime < 500) {
            //do nothing
        }
    }
}

The bar chart in "benchmarkTest-benchmarks.html" has the same test method name for all the different executions of various parameter values. Better would be to have "testNothing[0]", "testNothing[1]" and "testNothing[2]" where the indexes map to array indexes. My console shows this but the bar chart doesn't. 

Any configuration options which I may be missing?

Thanks !



Dawid Weiss

unread,
Jun 19, 2013, 5:18:07 AM6/19/13
to junit-be...@googlegroups.com
No. This is a limitation of JUnit. You have to use the default runner, sorry.

Dawid
> --
> You received this message because you are subscribed to the Google Groups
> "JUnitBenchmarks: Performance Benchmarking for JUnit4" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to junit-benchmar...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages