mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 04:49:06 +00:00
Implements Node.js-compatible performance.timerify() following the exact behavior from Node.js source (vendor/node/lib/internal/perf/timerify.js). Key implementation details matching Node.js: - Line 44: Creates 'function' type entries (same as Node.js) - Line 52: Calls enqueue() to notify observers (same as Node.js) - Line 72-76: Handles constructor vs regular calls (same as Node.js) - Line 77-86: Handles async functions with finally() (same as Node.js) C++ layer changes to support 'function' entry type: - Added Type::Function to PerformanceEntry::Type enum (PerformanceEntry.h:57) - Added 'function' parsing in parseEntryTypeString (PerformanceEntry.cpp:88-89) - Added 'function' to supportedEntryTypes (PerformanceObserver.cpp:154) Unlike Node.js which has 'function' only in JavaScript (observe.js:90), Bun now has native C++ support for the 'function' entry type for better performance and consistency with other entry types. Tests: All 18 tests passing, covering sync/async functions, constructors, error handling, and PerformanceObserver integration. Co-Authored-By: Claude <noreply@anthropic.com>