Coding task · JavaScript and TypeScript course · Module 9: Design Patterns and Architecture

Exercise: Performance Monitoring

Implement a performance monitor that measures the time of operations and builds a metrics report.

Task

The index.js file has a PerformanceMonitor class. Fill in the blanks: ___BLANK1___ is the method of the performance object that returns the current time in milliseconds with high precision (measure uses the same method for the end time), ___BLANK2___ is the array method that adds up all durations (it starts from 0), and ___BLANK3___ is the Math method that returns the largest duration. measure(name, fn) should return the result of fn and store the measurement { name, duration }, and getReport(name) should return { count, min, max, avg } for the measurements with this name, or null when there are none.