Benchmark and Compare Execution Time of Async vs Sync JavaScript Functions

Build a performance measurement utility that wraps both synchronous and asynchronous functions and accurately measures their execution time using performance.now() or the Performance API. Handle async functions correctly by awaiting resolution before recording the end time. Support multiple runs and averaging for statistical accuracy. This utility is used in profiling tools, benchmarking suites, and anywhere you need to quantify the overhead of async operations.

Examples
Input: []
Output:
Hints

Benchmark and Compare Execution Time of Async vs Sync JavaScript Functions

Build a performance measurement utility that wraps both synchronous and asynchronous functions and accurately measures their execution time using performance.now() or the Performance API. Handle async functions correctly by awaiting resolution before recording the end time. Support multiple runs and averaging for statistical accuracy. This utility is used in profiling tools, benchmarking suites, and anywhere you need to quantify the overhead of async operations.