Home
← All questions

measureFunctionPerformance for sync and async functions in JavaScript

MediumPremiumJavaScript

Asked at Atlassian

JavaScript interview practice: Measure average execution time of a sync or async function over N iterations.

Problem

Implement measureFunctionPerformance(fn, iterations = 1000, label = 'Function', callback = null) that runs fn iterations times (awaiting if it returns a promise) and reports the average time via the callback.

Premium question

Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.

Unlock with Premium