0

The JVM Tool Interface has several call-stack related functions (e.g., GetStackTrace, GetFrameCount, or GetLocalInstance) which take a jthread as argument to determine the affected thread. All of them take a NULL argument to mean “the current thread.“

Now suppose I already have a jthread referring to the current thread. Which one is then faster?

  1. Explicitly passing the current thread as jthread
  2. Passing NULL
Andreas Sewe
  • 1,558
  • 9
  • 18
  • What about running a test and measuring it? – Yexo Oct 19 '16 at 11:53
  • I did that already using the [DaCapo Benchmark Suite](http://www.dacapobench.org/) frequently used in research: Any difference in performance is lost in the noise introduced by JIT compilation, garbage collection, etc. So I know the performance difference to be small. Still, I was hoping for an answer along the lines of “option 1 is slower than option 2 because an extra lookup is involved internally” to squeeze out the last bit of performance. – Andreas Sewe Oct 20 '16 at 07:04

0 Answers0