MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve io blocking perf

+23 -4
+18 -1
examples/test262/index.js
··· 57 57 searchQuery: '' 58 58 }; 59 59 60 + let fps = { 61 + frames: 0, 62 + lastTime: performance.now(), 63 + current: 0, 64 + update() { 65 + this.frames++; 66 + const now = performance.now(); 67 + const delta = now - this.lastTime; 68 + if (delta >= 1000) { 69 + this.current = Math.round((this.frames * 1000) / delta); 70 + this.frames = 0; 71 + this.lastTime = now; 72 + } 73 + } 74 + }; 75 + 60 76 function fmt(bytes) { 61 77 if (bytes < 1024) return bytes + ' B'; 62 78 if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB'; ··· 139 155 } 140 156 141 157 lines.push(''); 142 - lines.push(`${c.dim}[${idx + 1}/${total}]${c.reset}`); 158 + lines.push(`${c.dim}[${idx + 1}/${total}]${c.reset} ${c.cyan}${fps.current} fps${c.reset}`); 143 159 } else if (state.mode === 'stats') { 144 160 const headerWidth = Math.min(cols, 68); 145 161 lines.push(`${c.bold}${c.blue}${'โ•'.repeat(headerWidth)}${c.reset}`); ··· 214 230 } 215 231 216 232 function render() { 233 + fps.update(); 217 234 const screen = buildScreen(); 218 235 process.stdout.write(`${term.syncStart}${term.hideCursor}${term.home}${screen}${term.syncEnd}`); 219 236 }
+5 -3
src/ant.c
··· 1055 1055 work = get_pending_work(); 1056 1056 1057 1057 if (work & (WORK_READLINE | WORK_STDIN)) { 1058 - uv_run(uv_default_loop(), UV_RUN_NOWAIT); 1059 - int64_t ms = has_pending_timers() ? get_next_timer_timeout() : 20; 1060 - if (ms > 20) ms = 20; if (ms > 0) usleep((useconds_t)(ms * 1000)); 1058 + if (work & WORK_BLOCKING) uv_run(uv_default_loop(), UV_RUN_NOWAIT); else { 1059 + int64_t ms = has_pending_timers() ? get_next_timer_timeout() : 100; 1060 + if (ms > 100) ms = 100; 1061 + uv_run(uv_default_loop(), ms > 0 ? UV_RUN_ONCE : UV_RUN_NOWAIT); 1062 + } 1061 1063 } else if (!(work & WORK_BLOCKING) && (work & WORK_TIMERS)) { 1062 1064 jsoff_t gc_thresh = js->brk / 2; 1063 1065 if (gc_thresh < 4 * 1024 * 1024) gc_thresh = 4 * 1024 * 1024;