@Setup(Level.Invocation)

Ivan Gerasimov ivan.gerasimov at oracle.com
Wed Jul 9 14:05:40 UTC 2014


Hello!

I noticed a great influence of presence of @Setup(Level.Invocation) on 
some benchmark results.

This simple test gives the following numbers.

@State(Scope.Thread)
public class MyBenchmark {

//    @Setup(Level.Invocation)
//    public void setup() {}

     @Benchmark
     public int testMethod() {
         return 42;
     }
}

Benchmark                      Mode   Samples        Score  Score 
error    Units
o.s.MyBenchmark.testMethod    thrpt         5 521204947.564 
200284466.443    ops/s


When I uncomment the setup() function, the numbers drops to:

Benchmark                      Mode   Samples        Score  Score 
error    Units
o.s.MyBenchmark.testMethod    thrpt         5   120471.248 32030.457    
ops/s


Am I correct that it's not practical to use @Setup(Level.Invocation) 
with measuring anything that lasts less than a microsecond or something?

Sincerely yours,
Ivan



More information about the jmh-dev mailing list