最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Does JMH have a version of AssumptionViolatedException for not running certain benchmarks? - Stack Overflow

programmeradmin1浏览0评论

I've got a JMH benchmark with several @Param fields. The issue is that some param combinations are not valid - they are nonsensical.

Is there a way to mark a particular combination of params as 'not valid' during setup - so the benchmark is not run, but it is not marked as failure either? Similar to AssumptionViolatedException for JUnit?

ie I want to do the following:

@State(Scope.Benchmark)
public class JMH {

    @Param({"s1", "s2"})
    String param1;

    @Param({"s3", "s4"})
    String param2;

    @Setup
    public void setup() {
        if (param1.equals("s1") && param2.equals("s4")) {
            // this combination is not valid for the use case
            // this benchmark is for
            throw new DoNotBenchmarkException(); // just skip this one
        }
        // carry on and setup the benchmark...
    }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论