I am trying to use perf_hooks from the nodeJS Performance API in my React Native project. Below is my code
import {performance} from 'perf_hooks';export const measure = ( target: Object, propertyKey: string, descriptor: PropertyDescriptor) => { const originalMethod = descriptor.value; descriptor.value = function (...args) { const start = performance.now(); const result = originalMethod.apply(this, args); const finish = performance.now(); console.log(`Execution time: ${finish - start} milliseconds`); return result; }; return descriptor;};
I keep getting the same error.error: bundling failed: Error: Unable to resolve module perf_hooks
from src/utils/metrics.ts
: perf_hooks could not be found within the project.
Performance API is available from node version 8.x and my node -v response is 10.16.1.
I see that there is perf_hooks present in my node_modules as well under the @types/node/perf_hooks
folder.