It's not a secret anymore!
The moose likes Java in General and the fly likes Warmup code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Warmup code" Watch "Warmup code" New topic

Warmup code

Rajdeep Biswas
Ranch Hand

Joined: Mar 26, 2012
Posts: 187

Hi, I want to run a few performance tests. So I need guidance on how to add warmup code for JVM, so that the warming up of JVM has no effect on the benchmark test results.
Thank you

The biggest gamble will be to ask a question whose answer you know in that it will challenge your theory |
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

Writing good performance benchmark code in Java is very hard because of the many sophisticated optimizations that the JVM and the JIT do and because of garbage collection, which happens at unpredictable times.

Some links:
Java theory and practice: Dynamic compilation and performance measurement
Java theory and practice: Anatomy of a flawed microbenchmark

Don't take the results of any micro-benchmark too seriously. Your real, production code might just behave and optimize slightly differently and have different performance characteristics than what you saw in your micro-benchmark.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Warmup code
It's not a secret anymore!