Java loop gets slower after some runs / JIT's fault?

前端 未结 3 598
执笔经年
执笔经年 2020-12-05 15:44

So I wanted to benchmark some basic java functionality to add some imformation to this question: What is the gain from declaring a method as static.

I know writing b

3条回答
  •  鱼传尺愫
    2020-12-05 16:41

    Just one additional Note. I can only observe this strange behavior if I use long for r and is. If I convert them to int then I get these timings:

    Static: 352 ms
    Dynamic: 353 ms
    Static: 348 ms
    Dynamic: 349 ms
    Static: 349 ms
    Dynamic: 348 ms
    Static: 349 ms
    Dynamic: 344 ms
    

    So one possible conclusion is to avoid long in those situations. At least with Linux/Amd64 Java7 where perfomance matters.

提交回复
热议问题