This question suggests using console.time
, but that isn't available in React Native. Is there a built in way to measure how long a function call takes, without using any third-party packages?
Define a function that takes the number of milliseconds as parameter. Use the setTimeout method to resolve a Promise after the provided number of milliseconds.
To get the current datetime in react native has the Date() object it will return every time the current date and time when we use it. we have to just write new Date() and it returns the date object where we get a year, month, date, hours, minutes, and seconds.
Starts a timer you can use to track how long an operation takes. When you call console. timeEnd()/console. timeLog() with the same name, the react-native will output the time, in milliseconds, that elapsed since the timer was started.
I ran into the same error but managed to fix it easily, just enable debugging on your app to use chrome or react native debugger. From the console of these debuggers, the console.time() and console.timeEnd() is supported and works perfectly
Using react-native v0.63 (not sure about lower versions), you can use the performance
api, which is described in the question you linked in the OP.
var t0 = performance.now()
doSomething() // <---- measured code goes between t0 and t1
var t1 = performance.now()
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With