js性能测试——for循环
来源:互联网 发布:华为数据存储解决方案 编辑:程序博客网 时间:2024/04/28 05:54
js性能测试——for循环
首先请看下测试用例:documenttest.html
<script type="text/javascript">
var TEST = (function() {
function _test1() {
//test document.cookie
var s = new Date();
for(var i=0;i<100000;i++) {
var a = document.cookie;
}
var e = new Date();
console.log(e-s);
}
function _test2() {
//test window.document.cookie
var s = new Date();
for(var i=0;i<100000;i++) {
var a = window.document.cookie;
}
var e = new Date();
console.log(e-s);
}
return {
test1 : _test1,
test2 : _test2
};
})();
TEST.test1();
TEST.test2();
</script>
chrome 输出结果为:
10615 documenttest.html:14
10713 documenttest.html:27
Firefox 输出结果为:
164 documenttest.html (line 14)
194 documenttest.html (line 27)
Safari 输出结果为:
2661 documenttest.html:14
2684 documenttest.html:27
chrome处理for循环的效率真低啊
首先请看下测试用例:documenttest.html
<script type="text/javascript">
var TEST = (function() {
function _test1() {
//test document.cookie
var s = new Date();
for(var i=0;i<100000;i++) {
var a = document.cookie;
}
var e = new Date();
console.log(e-s);
}
function _test2() {
//test window.document.cookie
var s = new Date();
for(var i=0;i<100000;i++) {
var a = window.document.cookie;
}
var e = new Date();
console.log(e-s);
}
return {
test1 : _test1,
test2 : _test2
};
})();
TEST.test1();
TEST.test2();
</script>
chrome 输出结果为:
10615 documenttest.html:14
10713 documenttest.html:27
Firefox 输出结果为:
164 documenttest.html (line 14)
194 documenttest.html (line 27)
Safari 输出结果为:
2661 documenttest.html:14
2684 documenttest.html:27
chrome处理for循环的效率真低啊
- js性能测试——for循环
- for循环性能测试
- java 中for循环的性能测试
- JS--for循环的性能优化
- js for循环 setTimeout与setInterval测试
- for循环 forEach 新循环 用法及性能测试
- 全面测试JAVA各种循环的性能,for轻松胜出
- OC自动释放池在for循环中的性能测试
- JS for与for in对比(包含性能测试)
- js for循环高性能高逼格细节分析
- for 循环嵌套性能
- for循环1-性能
- for循环优化 测试
- js高性能循环
- JS For 循环
- js的for循环
- js for 循环
- js for循环异步
- 关于font face="Webdings"的用法
- hdu 4158 GO
- 纯新手DSP编程--5.31--DSP/BIOS中的数据交换
- CATransition的动画效果类型及实现方法
- 订书器
- js性能测试——for循环
- faye 如何push json数据到客户端?
- IIC
- Droid-Fu介绍二: WebImageView and WebGalleryAdapter
- android开发内存泄露优化详解新手注意了
- C++中的模板的两种编译模型
- vi 打开多个文件
- SQL SERVER 2005-OVER (PARTITION BY…)的用法
- android导入第三方包所遇到的NoClassDefFoundError错误