java - How to get rid of "Method parameters should be @State classes" in JMH when parameters come from another method? -
i'm working on maven project. scenario below...
class test { public void applyall() { .................... .................... collection<migratable> applicableupdates = someotherclass.getapplicableupdates(); doupdate(applicableupdates); } @benchmark public void apply(migratable m) { .................... .................... } private void doupdate(collection<migratable> applicableupdates) throws exception { (migratable m : applicableupdates) { try { apply(m); } catch (exception e) { logger.error("falid apply migration {}" + m, e); throw e; } } } }
i need compute how long takes execute each migration. need compute execution time of apply(migratable m) method.
now, when build project using "mvn clean install", build failed , shows "method parameters should @state classes".
here, parameter comes method doupdate(collection applicableupdates) [see scenario]. how can rid of error in given scenario?
there quite few problems in setup here , seems haven't looked @ samples of jmh; , advise that.
a few notes...
1) @benchmark
method returns void - should return something
; otherwise use blackholes
(this in samples).
2) if parameters comes another method means method should @setup
method (this in samples)
3) error seeing has fact migratable
not @state
class (this again in samples!)
at point can't stress enough - , understand samples. it's not going easy, micro-benchmark , as jmh tries make things easier hiding very complicated code, still requires convey rules exist there.
Comments
Post a Comment