JVM-20130325

class a {

    public static int addmult(int x, int y, int z) {
       int temp = x + y;
       return z * temp;
    }

    public static int cal1(int x, int y, int z) {
       int sum = 0;
       for(int i = 0; i < 8000; i++) {
          sum += addmult(x, y, z);
       }
       return sum;
    }

    public static int cal2(int x, int y, int z) {
       int sum = 0;
       for(int i = 0; i < 8000; i++) {
          sum += addmult(x, y, z);
       }
       return sum;
    }

    public static void main (String args[]) {
long startTime = System.currentTimeMillis();
        int x = 1;
        int y = 1;
        int z = 1;
        a.cal1(x, y, z);
        a.cal2(x, y, z);
long endTime = System.currentTimeMillis();
        System.err.println("time: "+ (endTime - startTime)+" z = "+z);
        }
}


 11     Parm    ===  3  [[ 24 ]] Parm1: int !jvms: a::addmult @ bci:-1
 10     Parm    ===  3  [[ 24 ]] Parm0: int !jvms: a::addmult @ bci:-1
 24     AddI    === _  10  11  [[ 25 ]]  !jvms: a::addmult @ bci:2
 12     Parm    ===  3  [[ 25 ]] Parm2: int !jvms: a::addmult @ bci:-1
 3      Start   ===  3  0  [[ 3  5  6  7  8  9  10  11  12 ]]  #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address, 5:int, 6:int, 7:int}
 25     MulI    === _  12  24  [[ 26 ]]  !jvms: a::addmult @ bci:6
 9      Parm    ===  3  [[ 26 ]] ReturnAdr !jvms: a::addmult @ bci:-1
 8      Parm    ===  3  [[ 26 ]] FramePtr !jvms: a::addmult @ bci:-1
 7      Parm    ===  3  [[ 26 ]] Memory  Memory: @BotPTR *+bot, idx=Bot; !jvms: a::addmult @ bci:-1
 6      Parm    ===  3  [[ 26 ]] I_O !jvms: a::addmult @ bci:-1
 5      Parm    ===  3  [[ 26 ]] Control !jvms: a::addmult @ bci:-1
 26     Return  ===  5  6  7  8  9 returns 25  [[ 0 ]]
 0      Root    ===  0  26  [[ 0  1  3 ]] inner

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值