4 ms·
As an anecdote: I had been running a Z80 emulator on my website (http://8bitworkshop.com http://8bitworkshop.com) and I began to notice persistent 30-second del
by sehugg 9y ago
As an anecdote: I had been running a Z80 emulator on my website (http://8bitworkshop.com http://8bitworkshop.com) and I began to notice persistent 30-second delays on Firefox. It was difficult to track down, but I suspected the Z80 interpreter which had a gigantic switch statement. The optimizer must have been choking on it.
After refactoring each opcode handler into separate functions, it now runs with several subsecond delays on startup (as the various code paths are discovered and optimized, I suppose) and with no delays after a minute or so.
WebAssembly won't have this problem (neither does asm.js, but that's a different story...)