All files / src emulation-tick.js

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12        16x   16x 16x     93x  
// The page runs the machine in short slices of real time on a timer (src/web/emulation-loop.js), whatever the
// display is doing (issue #885). Audio gains most from the fine grain: its queue need only cover a slice. Whatever
// else runs execute() (the benchmarks, the same-answer check) uses slices of this size too, to call it as the
// page does: its exit deopts, so the slice size changes what runs.
export const TickMs = 10;
// The PAL picture's 50 fields a second, used for the Atom's 60 Hz picture too.
export const FramesPerSecond = 50;
const MsPerSecond = 1000;
 
/** The CPU cycles one tick runs on a machine of `cyclesPerSecond`. */
export const tickCycles = (cyclesPerSecond) => (cyclesPerSecond * TickMs) / MsPerSecond;