feat: Add timing/performance logging to Logger class#2
feat: Add timing/performance logging to Logger class#2tsadrakula wants to merge 1 commit intomainfrom
Conversation
Add startTimer, endTimer, getTimingReport, and clearTimings methods for measuring and logging operation durations with formatted output. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| */ | ||
| startTimer(label: string): void { | ||
| this.timings.set(label, { | ||
| label, |
There was a problem hiding this comment.
MAJOR (80% confidence)
Using Date.now() for timing measurements can be inaccurate due to system clock adjustments. Consider using performance.now() for more precise timing measurements, especially for performance monitoring.
| this.warning(`Timer "${label}" was never started`); | ||
| return 0; | ||
| } | ||
|
|
There was a problem hiding this comment.
MINOR (90% confidence)
Redundant Date.now() call - you're calculating duration correctly but then overwriting entry.endTime with a new timestamp. Should be: entry.endTime = entry.startTime + duration;
| */ | ||
| endTimer(label: string): number { | ||
| const entry = this.timings.get(label); | ||
| if (!entry) { |
There was a problem hiding this comment.
MINOR (70% confidence)
Returning 0 for non-existent timers could mask bugs. Consider throwing an error or returning null/undefined to make the error more explicit to calling code.
| const mins = Math.floor(duration / 60000); | ||
| const secs = ((duration % 60000) / 1000).toFixed(1); | ||
| durationStr = `${mins}m ${secs}s`; | ||
| } |
There was a problem hiding this comment.
MINOR (80% confidence)
The endTimer method always logs to console regardless of verbose setting, while startTimer respects it. Consider making this behavior consistent - either both respect verbose or both always log.
Add startTimer, endTimer, getTimingReport, and clearTimings methods for measuring and logging operation durations with formatted output.