How to be reasonably sure a code block has been JIT compiled?

Viewed 559

When conducting performance testing of java code, you want to test JIT compiled code, rather than raw bytecode. To cause the bytecode to be compiled, you must trigger the compilation to occur by executing the code a number of times, and also allow enough yield time for the background thread to complete the compilation.

  • What is the minimum number of "warm up" executions of a code path required to be "very confident" that the code will be JIT compiled?
  • What is the minimum sleep time of the main thread to be "very confident" that the compilation has completed (assuming a smallish code block)?

I'm looking for a threshold that would safely apply in any modern OS, say Mac OS or Windows for the development environment and Linux for CI/production.

3 Answers
Related