【问题标题】:Measuring the Performance with the Hermes Engine使用 Hermes 引擎测量性能
【发布时间】:2021-10-27 13:43:13
【问题描述】:

我正在尝试在 React Native 中进行分析并使用 hermes 引擎。我想测量函数调用之间的时间。 在 Js 中我们可以使用 console.time 或 performace.now 但是当我将这些功能与 hermes 引擎一起使用时,我得到 "Undefined is not a function" 错误。

当我使用 Chrome 调试器运行相同的代码时,它工作正常。

谁能建议我如何使用 hermes 引擎实现以下代码。

const checkTime = () => {
   console.time('time_NoOp');
   doNothing();
   console.timeEnd('time_NoOp');
   
};   

.

【问题讨论】:

  • 前后可以用Date.now(),两者相减。确保使用编译后的字节码在发布模式下测量 Hermes,因为在开发模式下从源代码运行速度要慢得多,尤其是在加载时。

标签: javascript react-native javascript-engine react-native-hermes


【解决方案1】:

更新:

我可以使用以下代码解决问题

const PerformanceTime=() => {
   const t0 = performance.now();
   doNothing();
   const t1 = performance.now();
   console.log(t1 - t0);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-15
    • 2022-11-29
    • 2022-11-02
    • 2022-10-23
    • 2022-12-17
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    相关资源
    最近更新 更多