标签:style blog http java color io
今天发现一个小技巧,计算执行一段代码所需的时间(精确到毫秒),此段代码也显示了尽量少用with
//取值与赋值 10000 function noWith(){ var obj = a.a.a.a.a.a.a, i=100000, j = 0; for(; i; i--){ j = obj.b; obj.b = i; } } //取值与赋值 10000 function yesWith(){ var i=100000, j = 0; with( a.a.a.a.a.a.a ){ for(; i; i--){ j = b; b = i; } } } var t = new Date().getTime(); //noWith(); noWith(); cc.log(new Date().getTime() - t);
标签:style blog http java color io
原文地址:http://www.cnblogs.com/rhythm2014/p/3698790.html