Computer scienceBackendNode.jsCore ConceptsInternal modulesPerformance measurement

Intro to performance hooks

Measuring the Performance of fetch

Report a typo

You've defined a function to fetch data. Now, you'll want to see how long this async function fetchData takes to complete its execution. To achieve this, use the PerformanceObserver class. Remember, there's no need to call the fetchData function again; it's already been called for you, with performance entry points marked. You should only log the duration of this performance entry, and make sure it's in milliseconds.

Write a program in JavaScript
const { PerformanceObserver } = require('perf_hooks');

// Create a performance observer to measure the duration of the asynchronous function

Create a free account to access the full topic