I achieved 100% results this way:
- Configure Bochs with MS-DOS.
- Configure your binding to the target MS-DOS
- or -- Configure your 32-bit Windows targeting toolchain
- Install the HX-DOS Extender in Bochs.
- If necessary, hack the standard library / runtime of the tools and run / remove functions that require the use of Windows APIs that are not implemented in HX-DOS. When you try to start the program, the expander will print a list of failed APIs.
- Reduce the number of cycles in your test by several orders of magnitude.
- Wrap the test code using the
cli / sti assembler instructions (note that after this change, the binary will not work on modern operating systems). - If you havenโt done so yet, do your test to use
rdtsc deltas to select a time. Samples must be in cli & hellip; sti . - Launch it in Bochs!

The result seems completely deterministic, but not an accurate estimate of overall performance (see discussion in Osman Turan's answer for details).
As a bonus tip, you can easily share files with Bochs here (so you donโt need to disconnect / rebuild / mount the floppy disk image every time):
On Windows, Boch blocks a floppy disk image file, but the file is still open in shared write mode. This means that you cannot overwrite the file, but you can write it. (I think * nix OSes can overwrite to create a new file as far as file descriptors are concerned.) The trick is to use dd . I had the following script installation:
... benchmark build commands here ... copy /YC:\Path\To\Benchmark\Project\test2dos.exe floppy\test2.exe bfi -t=288 -f=floppysrc.img floppy dd if=floppysrc.img of=floppy.img
bfi is Bart Build a floppy image .
Then just install floppy.img in Bochs.
Bonus Tip # 2: To avoid having to manually run the test every time in Bochs, put the empty go.txt file in the floppy disk directory and run this batch in Bochs:
@echo off A: :loop choice /T:y,1 > nul if not exist go.txt goto loop del go.txt echo --------------------------------------------------- test2 goto loop
It runs a test program every time it detects a fresh floppy disk. Thus, you can automate the launch of the test in one script.
Update: this method is not very reliable. Sometimes the timings would change by as much as 200%, simply reordering some tests (these time changes were not observed when working on real hardware, using the methods described in the original question).
source share