// Bun-specific optimizations export function optimizeForBun() { try { // More comprehensive Bun detection const isBun = typeof global.Bun !== 'undefined' && typeof Bun !== 'undefined' && Bun.version !== undefined; if (isBun) { // Enable Bun's performance optimizations process.env.BUN_RUNTIME_ENV = 'production'; // Configure Bun's garbage collection safely if (typeof global.gc === 'function') { try { global.gc(); } catch (gcError) { console.warn('GC optimization failed:', gcError.message); } } // Enable Bun-specific optimizations if (typeof Bun.gc === 'function') { try { Bun.gc(false); // Conservative GC } catch (bunGcError) { console.warn('Bun GC optimization failed:', bunGcError.message); } } return true; } } catch (error) { console.warn('Bun optimization failed:', error.message); } return false; } export function getBunMetrics() { try { // More comprehensive Bun detection const isBun = typeof global.Bun !== 'undefined' && typeof Bun !== 'undefined' && Bun.version !== undefined; if (isBun) { return { version: Bun.version, revision: Bun.revision || 'unknown', cpuUsage: process.cpuUsage(), memoryUsage: process.memoryUsage(), platform: process.platform, arch: process.arch, pid: process.pid }; } } catch (error) { console.warn('Failed to get Bun metrics:', error.message); } return null; }