console.timeLog

I work on a really complex debugger at Mozilla but, and don't tell my colleagues, I sometimes enjoy simply using console.log and other console commands to get some simple output.  I know, I know, but hey -- whatever gets the job done.  A few years ago I detailed console.time and console.timeEnd for measuring time for a given set of tasks; let me show you console.timeLog, a new function in Firefox Nightly for logging events during a console.time timer!

我在Mozilla上开发了一个非常复杂的调试器 ,但是,不告诉同事,有时我会喜欢简单地使用console.log和其他console命令来获得一些简单的输出。 我知道,但是,嘿-一切都能完成。 几年前,我详细介绍了console.time console.timeEnd用于测量给定任务集的时间。 让我向您展示console.timeLog ,这是Firefox Nightly中的一项新功能,用于在console.time计时器期间记录事件!

Start by kicking off the timer with a name of your choice:

首先使用您选择的名称启动计时器:


console.time("MyApp");


Whenever you want the intermediate timer value, as well as extra information like variable or object values, you can use console.timeLog:

每当您需要中间计时器值以及诸如变量或对象值之类的额外信息时,都可以使用console.timeLog


// Same timer name, provide sublabel and optional info
console.timeLog("MyApp", "constructor"); 
// MyApp: 4ms constructor

console.timeLog("MyApp", "render", this.state);
// MyApp: 2ms render Object { disabled: false }


When your timed tasks have completed, you can call console.timeEnd to stop the timer:

定时任务完成后,可以调用console.timeEnd停止计时器:


console.timeEnd("MyApp");
// MyApp: 10ms


Firefox has a Performance tab for very detailed performance metrics but, as always, the console is a great way to get some basic insight at a glance.  The timeLog function is an awesome way to get intermediate timing and information while your script runs!

Firefox的“性能”选项卡提供了非常详细的性能指标,但是与往常一样,控制台是一目了然的基本了解的好方法。 timeLog函数是一种很棒的方式,可以在脚本运行时获取中间时间和信息!

翻译自: https://davidwalsh.name/console-timelog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值