2

I am trying to profiling in React Native and using hermes engine. I want measure the time in between a function call. In Js We can use console.time or performace.now but when I am using those fucntion with hermes engine I am getting "Undefined is not a function" Error.

When I am running the same code with Chrome debugger it is working fine.

Can anyone suggest how i can implement the below code with the hermes engine.

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

.

enter image description here

rahul goyal
  • 125
  • 2
  • 8
  • 1
    You can use [Date.now()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) before and after, and subtract the two. Make sure to measure Hermes in release mode with compiled bytecode, as running from source in dev mode is significantly slower, especially on load. – that other guy Oct 29 '21 at 20:34

1 Answers1

1

Update:

I am able to solve the problem by using the below code

const PerformanceTime=() => {
   const t0 = performance.now();
   doNothing();
   const t1 = performance.now();
   console.log(t1 - t0);
}
rahul goyal
  • 125
  • 2
  • 8