In today’s challenge, we build a utility function measureExecutionTime to calculate how long a given function takes to run. This function supports both synchronous and asynchronous executions.
We use performance.now() for high-precision timing and ensure that results are logged in milliseconds. Whether the function returns a value instantly or involves async operations like API calls or delays, our utility captures and logs the execution duration.
This problem helps strengthen your understanding of:
Handling sync vs async functions uniformly
Using try/catch for error handling
Working with high-precision timers in JavaScript
Writing reusable utility functions.