0

I'm trying to measure how much time it takes for a promise to resolve. However, I'm getting a "perfomance' is not defined" error even though I have node 15+. Ive also tried putting in

const {performance} = require('perf_hooks');

in my code but no luck.

I'm doing this in React, but I doubt that is making a difference.

nullItems
  • 1
  • 1

1 Answers1

1

I have node 15+

I'm doing this in React, but I doubt that is making a difference.

React runs client side.

You might use Node.js to transpile JSX and modern JS into a lower level of JS that can be understood by browsers, but the program ends up running in the browser and not on Node.js (unless you are also using server-side rendering, but then you need to carefully differentiate what can run only server- or client-side).

This question addresses a number of ways to performance test code in the browser.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335