【问题标题】:How can I display own Events in Chrome dev tools如何在 Chrome 开发工具中显示自己的事件
【发布时间】:2013-08-09 07:27:16
【问题描述】:

我想测量我的应用程序,它对性能非常敏感。

为此,我想知道 Chrome 开发工具或其他工具中是否有一个选项可以获取类似于“网络”选项卡中提供的视图,但其中包含我自己的 JS 触发事件(例如红/蓝线)。

有办法吗?

【问题讨论】:

    标签: javascript performance google-chrome google-chrome-devtools


    【解决方案1】:

    显而易见的解决方案是使用控制台。它为您提供了比简单的console.log更多的工具:

    • 格式化 (console.log("%cThis will be formatted with large, blue text", "color: blue; font-size: x-large");)

    • 测量时间 (console.time("Array initialize"); longRunningOperation(); console.timeEnd("Array initialize");)


    (来源:google.com

    • 分组 (console.group("Authenticating user '%s'", user); authentication(); console.groupEnd();)


    (来源:google.com

    • 在时间线上标记事件 (console.timeStamp("Adding result");)


    (来源:google.com

    这应该足以创建自定义事件的可读日志。 See the official docs for more tips on using the Console.

    【讨论】:

    • 谢谢,最后一件事正是我要找的!
    猜你喜欢
    • 2023-03-18
    • 2019-08-25
    • 2013-08-27
    • 2020-06-15
    • 2015-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-03
    相关资源
    最近更新 更多