1
0
Fork 0
mirror of https://github.com/dosbox-staging/dosbox-staging synced 2025-12-04 16:27:29 -05:00
1 CPU tests
John Novak edited this page 2025-07-29 17:29:26 +10:00

CPU tests

Important

  • Always start Staging with --noprimaryconf.
  • Use the release build for the tests, then repeat with the debug build to make sure no asserts are tripped.
  • Optional, but recommended — create a custom release build for testing:
    • In dosbox.cpp, find increase_ticks() and change #if 0 to #if 1 inside the function, then create a release > build. This will log the momentary cycles values in auto-cycles mode.

Use the included #cpu-tests.zip test pack for the tests:

#cpu-tests.zip

Contents:

  • TESTS\KOPIO.EXE — Late '90s protected mode demo. Needs high cycles values to run smoothly, so the lower FPS gives a good indication that lower cycles values are in effect.

  • TESTS\TUBE.COM — Real mode 256-byte intro (yes!) that needs high cycles values to run smoothly (around ~80k to get stable FPS without frame drops).

  • TESTS\FT2.EXEFast Tracker II. It uses protected mode, so it's useful to get quickly in and out of pmode.

  • TESTS\SC.BAT — Helper batch file to print the current moder cpu_* settings to the console.

  • NO\*.*No by NoooN (demo). Uses protected mode, good general test case.

  • STARS\*.*Stars by NoooN (demo). Uses protected mode, good general test case, and it does some weird switching between real and pmode at startup with highlighted a few regressions with my modern implementation (the whole process crashed after a few seconds of starting the demo).

"Modern" cpu_* tests

Basic tests

  • Start with --noprimaryconf and the included dosbox.conf (note all cycles settings are commented out; don't touch them yet).
  • Confirm there are no cycles related warning messages in the logs with CPU: prefix.
  • Run SC.BAT and confirm the default values:
    • cpu_cycles — 3000
    • cpu_cycles_protected — 60,000
    • cpu_throttle — false
  • Run FT2. Now we're in pmode, so confirm the title bar shows 60000 cycles/ms.
  • Exit to DOS (Esc, then Enter).
  • We're back to real mode, confirm the title bar shows 3000 cycles.

Fixed settings

  • Start with --noprimaryconf and the included dosbox.conf.
  • Set cpu_cycles 1234 and confirm the setting in the title bar.
  • Set cpu_cycles_protected 65432 (no change in the title bar, we're in real mode).
  • Start FT2, confirm 65432 cycles in the title bar.
  • Exit, confirm 1234 cycles has been restored.
  • Press Cmd/Ctrl+F12 twice to increase the real mode cycles; the title bar should show 1493 cycles.
  • Confirm the cpu_cycles setting is kept in sync (just run cpu_cycles, or SC.BAT).
  • Start FT2, press Cmd/Ctrl+F12 three times so the title bar shows 37866 cycles.
  • Exit, confirm the title bar shows 1493 cycles, then run SC and confirm the cpu_* settings are synced:
    • cpu_cycles — 1493
    • cpu_cycles_protected — 37,866
    • cpu_throttle — false
  • Start FT2 one more time to double-check 37866 is the new pmode setting.
  • Exit and confirm we're back to 1493 cycles in real mode.

Throttled — general

  • Start with --noprimaryconf and the included dosbox.conf.
  • Run cpu_throttle on, confirm the title bar shows "3000 cycles (throttled)".
  • Repeat the "Fixed settings" tests and make sure throttled mode stays on.
  • At the end, turn off throttling with cpu_throttle off. Confirm that the last set settings have been retained in both real and protected mode.

Throttling — real mode

  • Start with --noprimaryconf and the included dosbox.conf.
  • Set cpu_throttle on, then cpu_cycles 1000000 (1 million). Confirm in the logs that the momentary cycles value however aroud 300k-400k actual cycles.
  • Start TUBE. Confirm the title bar shows 1000000 cycles, the animation is smooth with no frame drops, and the momentary cycles value is around 100-140k in the logs.
  • Exit with Esc, then turn off throttled mode (cpu_throttle off). Confirm the title bar still shows 10000000. Run SC, confirm cpu_cycles is still 10000000.
  • Turn throttling on again, set cpu_cycles 30000.
  • Start TUBE, confirm the momentary cycles stays at 30000.
  • Don't exit yet! 😎

Throttling — protected mode

  • Start KOPIO. Confirm we're in 60,000 cycles throttled mode (that's the protected mode default). Note the frame rate is quite choppy.
  • Exit back to real mode with Esc, confirm we're in 1,000,000 cycles throttled mode.
  • Set cpu_cycles_protected 200000 then start KOPIO. Note the frame rate is now 100% smooth.
  • Esc, confirm the correct real mode setting, then start KOPIO again.
  • Use Cmd/Ctrl+F11 to decrease the cycles to under 100k, note the animation became choppy.
  • Increase the cycles with Cmd/Ctrl+F12 until the animation becomes smooth again, they keep increasing until about 1 million cycles. Confirm in the logs that the momentary cycles values is around 400-500k because of the throttling. Note down the cycles number in the titlebar.
  • Exit with Esc, the restart KOPIO. Confirm the previous protected cycles setting was restored.
  • Check with SC.BAT that the config values are correct and reflect the cycles values set by the hotkeys.

Max cycles — global

  • Start with --noprimaryconf and the included dosbox.conf.
  • Set cpu_cycles max. Confirm the title bar shows "max cycles/ms" and the logs will show the momentary cycles value (around 350k on my M1 Mac).
  • Also confirmt the following warning appeared in the logs:
    • CPU: Invalid 'cpu_cycles_protected' setting: '60000'; fixed values are not allowed if 'cpu_cycles' is 'max', using 'auto'
  • Run SC.BAT, and confirm the config setting values:
    • cpu_cyclesmax
    • cpu_cycles_protectedauto
    • cpu_throttlefalse (has no effect in "max cycles" mode)
  • Start TUBE (real mode). Confirm the title bar still shows "max cycles/ms", the animation is smooth with no frame drops, and the momentary cycles value is around 100-140k in the logs.
  • Confirm the increase/decrease cycles hotkeys have no effect.
  • Exit with Esc, then start KOPIO (protected mode). Confirm the same things as per above.
  • Set cpu_throttle on and confirm "(throttled)" doesn't show up in the title bar after the cycles setting in real mode (so you should see "max cycles/ms" only).

Max cycles — protected mode only

  • Start with --noprimaryconf and the included dosbox.conf.
  • Set cpu_cycles_protected max and cpu_cycles 20000. Confirm the title bar shows 20,000 cycles.
  • Start TUBE and confirm it's really laggy at 20k cycles.
  • Modify the current cycles value with the hotkeys, then exit with Esc.
  • Confirm that the real mode cycles value is retained.
  • Start KOPIO (pmode). The animation should be perfectly smooth at "max cycles", confirm "max cycles" shows up in the title bar, etc.
  • Exit with Esc, confirm the previously set real mode cycles setting is restored.
  • Set cpu_throttle on and confirm "(throttled)" doesn't show up in the title bar after the cycles setting in protected mode (so you should see "max cycles/ms" only).

Cycles limits

  • Keep pressing the decrease cycles hotkey and confirm you can't go below 50.
  • Set cpu_throttle on and cpu_cycles 1000000 (1 million). Keep pressing the increase cycles hotkey and confirm you can't go above 2,000,000.
  • Try setting cpu_cycles and cpu_cycles_throttled values outside of the valid 50 to 2,000,000 range. Confirm a warning is logged and the value is clamped to the valid range. Also confirm with SC.BAT the config settings are kept in sync with the actual clamped values.

"Legacy mode" tests (cycles setting)

TODO