Set a system property before forking
Aleksey Shipilev
shade at redhat.com
Tue Mar 28 09:01:29 UTC 2017
Hi,
On 03/28/2017 08:29 AM, Weijun Wang wrote:
> I have a system property that is used by Java in a very early stage, which means
> it has to be set on the command line with -Dx=y instead of inside a program with
> System.setProperty().
>
> Now I'd like to write a benchmark to check how different values of this system
> property affect performance. I'm now able to provide the system property on the
> command line, run the benchmark multiple times, and compare the results. But is
> it possible to set it inside my benchmark with different values for different
> @Benchmark methods so I only need to run once? Since the @Benchmark methods run
> inside forked JVMs, I assume there is a way to set the system property before
> this forking.
This is not possible with annotations. This is possible with Java API and adding
.jvmArgs(...) to the options.
-Aleksey
More information about the jmh-dev
mailing list