How to get the output from console.timeEnd() in JS Console?

后端 未结 4 2004
感情败类
感情败类 2021-01-31 07:50

I\'d like to be able to get the string returned from console.timeEnd(\'t\') in my Google Chrome Javascript Console.

In this example below, I\'d like one var

4条回答
  •  盖世英雄少女心
    2021-01-31 08:29

    simply you can use

    var begin=Date.now();
    something here ...;
    var end= Date.now();
    
    var timeSpent=(end-begin)/1000+"secs";
    

    this is the simplest way and it will work on any browser not in only chrome

提交回复
热议问题