在循环100000次,且循环体中操作都是声明一个局部变量m。 3种耗时如下: foreach风格 :9130 normal for :12314 while :4258 可以看出while 性能最好,其次是for,其中for each 性能比for 高出30%。