[HTML 5 Performance] Benchmark functions runtime in chrome console
2021-04-01 01:26
                         标签:benchmark   console   span   ati   htm   OLE   fun   measure   ons    Sometimes you‘d like to measure how two implementations compare in regards to run time. In this lesson you will learn how to quickly do this using Console.time and constole.timeEnd.     [HTML 5 Performance] Benchmark functions runtime in chrome console 标签:benchmark   console   span   ati   htm   OLE   fun   measure   ons    原文地址:https://www.cnblogs.com/Answer1215/p/12576458.html    function runFaster() { 
      for (let i = 0; i ) {
        for (let j = 0; j ) {
          arr[i * ROWS + j] = 0;
        }
      }
    }
    function runSlower() {
      for (let i = 0; i ) {
        for (let j = 0; j ) {
          arr[j * ROWS + i] = 0;
        }
      }
    }
    const ROWS = 1000;
    const COLS = 1000;
    const arr = new Array(ROWS * COLS).fill(0);
    function testFunctionRuntime(repeats, functionToTest, logText = ‘Benchmarking‘) {
        console.time(logText);
        for (let i = 0; i ) {
            functionToTest();
        }
        console.timeEnd(logText);
    }
文章标题:[HTML 5 Performance] Benchmark functions runtime in chrome console
文章链接:http://soscw.com/index.php/essay/70711.html