Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Does Same byte code means same source code ? (I think no because I had different code each time)</p> </blockquote> <p>Not identical. For example, comments and white-space in the source code do not appear in the bytecodes. And neither do names of variables, and other things. (Variable names typically do appear elsewhere in the classfile though.)</p> <p>Also, it is possible for two equivalent expressions of the same algorithm to compile to the same bytecodes.</p> <blockquote> <p>How does same JVM gives different performance measurements for same bytecode.</p> </blockquote> <p>I can think of a number of reasons:</p> <ul> <li><p>It could simply be an artefact caused by poor design of your benchmark. A classic Java benchmarking mistake is to not properly take account of "JVM warmup" effects.</p></li> <li><p>It could be due to differences in the way you are calling the code.</p></li> <li><p>It could be due to differences in the inputs. (The JIT makes use of statistics gathered early in the execution to decide how to optimize the code. Different inputs could result in different execution stats ... and differently optimized code.)</p></li> <li><p>It could be due to other things happening on the system while you were doing your testing.</p></li> </ul> <hr> <blockquote> <p>Here are my performance readings in milliseconds Outside declaration of variable 10076ms Inside declaration of variable 10100 ms Outside declaration of variable 10130ms Inside declaration of variable 10274ms</p> </blockquote> <p>Differences that small could easily be due to hardware factors / environmental factors; e.g. CPU frequency scaling, or disc rotational latency. Note that the difference between 10076 and 10100 is SMALLER than the difference between 10076 and 10130.</p> <hr> <p>If you want a definitive answer, you will need to provide the complete code for your tests so that people can check for problems, and attempt to reproduce your results.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload