[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);
    }

原文地址:https://www.cnblogs.com/Answer1215/p/12576458.html

时间: 2024-08-29 19:58:14

[HTML 5 Performance] Benchmark functions runtime in chrome console的相关文章

use jQuery in chrome console

if a website does not have jQuery, and we want to use jQuery in chrome console. You can copy the code from here http://code.jquery.com/jquery-latest.min.js paste it into chrome console, then you are good to go. http://stackoverflow.com/questions/7474

关于 Chrome Console 查看DOM详情细节的奇思淫巧

我们期待打印出的dom效果如下: 但某些时候,打印出来,或者通过$0.$1.document.getElementById('####') 等方式打印出来的效果如下: 根据第一幅图我们不难看出,当打印出的是一个数组时,就chrome console就可以解析出我们理想的数据结构,所以,如果出现第二种时,我们可以套上一层数组 [ ] 再打印即可 如, [document.getElementById('app')] ,  如图所示: 原文地址:https://www.cnblogs.com/CyL

Ray tracing performance benchmark

accel. avg size 3.14accel. avg depth 16.15accel. max size 8accel. max depth 20accel. GPIT 3.00 MB trav. steps / ray 15.34isects / ray 10.13rps 174892.54 accel. avg size 3.16accel. avg depth 14.35accel. max size 16accel. max depth 56accel. GPIT 164.89

NPerf, A Performance Benchmark Framework for .Net0WG4

从IaaS.PaaS到CaaS IaaS 基础架构涉及IDC.机房.网络.主机等基础资源.机架设计和交付.网络架构设计.数据架构规划.操作系统.系统软件.环境交付和机器报废替换等.早期应用的开发和部署过程中大部分的工作不是关注于应用的研发,而是关注于基础环境的搭建,包括租用或者购买主机.搭建网络设施.部署系统及日志监控等基础软件.其开发部署效率低,整体成本高.IaaS基于虚拟化技术提供一种"随需应变"使用硬件资源的方式,它同时提供访问物理主机.存储和网络硬件等接口,使得用户能够按需创建

Chrome console(转)

阅读目录 写在前面 谷歌控制台Elements面板 查看元素上绑定的事情 样式操作 总况 console.log console.info console.error console.warn console.debug console.dirxml console.group和console.groupEnd console.assert console.count console.dir console.time和console.timeEnd console.profile和console

chrome console js多行输入

一直以来,Chrome控制台都缺少象IE调试台那样的多行执行模式.  今天意外发现Chrome其实也支持多行模式.默认在Chrome控制台上输入回车后会执行该命令,只需要通过输入Shift+Enter来新建行即可. 

Chrome console API

写在前面 大家都有用过各种类型的浏览器,每种浏览器都有自己的特色,本人拙见,在我用过的浏览器当中,我是最喜欢Chrome的,因为它对于调试脚本及前端设计调试都有它比其它浏览器有过之而无不及的地方.可能大家对console.log会有一定的了解,心里难免会想调试的时候用alert不就行了,干嘛还要用console.log这么一长串的字符串来替代alert输出信息呢,下面我就介绍一些调试的入门技巧,让你爱上console.log 先的简单介绍一下chrome的控制台,打开chrome浏览器,按f12

Firebug &amp; Chrome Console 控制台使用指南

转自:http://visionsky.blog.51cto.com/733317/543789 Console API 当打开 firebug (也包括 Chrome 等浏览器的自带调试工具),window 下面会注册一个叫做 console 的对象,它提供多种方法向控制台输出信息,供开发人员调试使用.下面是这些方法的一个简单介绍,适时地运用它们,对于提高开发效率很有帮助. console.log(object[, object, ...])使用频率最高的一条语句:向控制台输出一条消息.支持

在chrome console加入jquery库

var jq = document.createElement('script'); jq.src = 'http://libs.baidu.com/jquery/1.9.1/jquery.min.js'; document.getElementsByTagName('head')[0].appendChild(jq); jQuery.noConflict();