Spaces:
Sleeping
Sleeping
Download src/bun-optimizations.js from sacred-eye/pixelpinch-proxy: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/sacred-eye/pixelpinch-proxy/resolve/main/src/bun-optimizations.js
- Command line
-
hf download hf://spaces/sacred-eye/pixelpinch-proxy/src/bun-optimizations.js
-
curl -L -o bun-optimizations.js https://huggingface.co/spaces/sacred-eye/pixelpinch-proxy/resolve/main/src/bun-optimizations.js
1.74 kB
| // 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; | |
| } |