zoukankan      html  css  js  c++  java
  • [HTML 5 Performance] Benchmark functions runtime in chrome console

    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.

        function runFaster() { 
          for (let i = 0; i < ROWS; i++) {
            for (let j = 0; j < COLS; j++) {
              arr[i * ROWS + j] = 0;
            }
          }
        }
    
        function runSlower() {
          for (let i = 0; i < COLS; i++) {
            for (let j = 0; j < ROWS; 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 < repeats; i++) {
                functionToTest();
            }
            console.timeEnd(logText);
        }
  • 相关阅读:
    Kera高层API002
    Kera高层API
    手写数字问题实战(层)
    函数优化实战
    反向传播算法
    链式法则
    多输出感知机及其梯度
    JDBC
    mysql查询操作1
    内部类
  • 原文地址:https://www.cnblogs.com/Answer1215/p/12576458.html
Copyright © 2011-2022 走看看