Fwd: Integrate JMH in existing maven project
Nasimuzzaman Himel
nasimuzzaman.iit.du at gmail.com
Mon Apr 10 12:23:59 UTC 2017
---------- Forwarded message ----------
From: Nasimuzzaman Himel <nasimuzzaman.iit.du at gmail.com>
Date: Mon, Apr 10, 2017 at 3:47 PM
Subject: Integrate JMH in existing maven project
To: support at jenkov.com
Sir, I'm working on a maven project currently. I face some problem
integrating JMH on my existing project. So I have got a few question. Hope
you'll answer...
1. How to integrate JMH in existing maven project?
2. How to Benchmark a method that takes parameters from another method (See
below scenario)?
I need to compute the execution time of apply(Migratable m) method for each
time it is being called.
Note that Migratable is an interface.
*******************************Scenario********************************
class Test {
public void applyAll() {
....................
....................
Collection<migratable> applicableUpdates =
SomeOtherClass.getApplicableUpdates(int
index);
doUpdate(applicableUpdates);
}
@Benchmark
public void apply(Migratable m) {
....................
....................
}
private void doUpdate(Collection<migratable> applicableUpdates) throws
Exception {
for (Migratable m : applicableUpdates) {
try {
apply(m);
} catch (Exception e) {
logger.error("Falid to apply migration {}" + m, e);
throw e;
}
}
}
}
More information about the jmh-dev
mailing list