zoukankan      html  css  js  c++  java
  • js 测试性能

    console.time('querySelector');
    for(var i=0; i<1000; i++){
    document.querySelector('body');
    }
    console.timeEnd('querySelector');


    console.time('getElementById');
    for(var i=0; i<1000; i++){
    document.getElementById('body');
    }
    console.timeEnd('getElementById');

    结果:

    还可以用profile性能检测:

    var test = {
    test1 : 1,
    say : function(){
    console.log('hello');
    }
    }
    console.profile('test.say()');
    test.say();
    test.say();
    test.say();
    test.say();
    test.say();
    console.profileEnd('test.say()');

    结果:

  • 相关阅读:
    日报10.29
    日报10.28
    日报10.27
    周进度总结-6
    日报10.25
    日报10.23
    日报10.22
    日报10.21
    日报10.18
    STL bitset
  • 原文地址:https://www.cnblogs.com/wangluochong/p/7158295.html
Copyright © 2011-2022 走看看