What's the fastest C/C++ compiler for your retro DOS and Win32 projects?
To find out, I've compiled three C/C++ language benchmarks using a variety of DOS and
Win32 compilers, then measured the executables' run-time performance on a bunch of
platforms ranging from rather old to fairly modern. The rest of this post describes
the results.
The findings reported here are actually a few years old at the time of writing, but
I originally released them in scattered bits and pieces. Since there's been a
reasonable amount of interest, I've bundled them into this single post for
easier reference. And since it's been a few years, it's possible I've misplaced a
detail or two, so feel free to
send feedback.
As with any performance benchmark, it's possible that the results reported here have missed
an edge case, fallen for some pitfall, etc. So you should take the figures and conclusions
with a grain of salt.
If you want, you can jump directly to the final results,
or you can keep reading to find out how the results were arrived at.
For DOS, I used a 16-bit software rasterizer running in VGA 13h
spinning a textured sphere in the middle of the screen.
Its C source code is available,
and you can preview the benchmark in action below:
Preview the benchmark in DOSBox
According to the overall results (which are averages across all of the
individual benchmark runs), Microsoft Visual C++ 1.5 tended to compile the fastest
executable, followed by Open Watcom C/C++ 1.9 and Digital Mars C/C++ 8. The pure
C compilers – which are generally older than the C/C++ ones – tended
to produce the slowest programs.
Overall results for 16-bit DOS
Score (%) |
Compiler |
96 |
Microsoft Visual C++ 1.5 |
91 |
Open Watcom C/C++ 1.9 |
84 |
Digital Mars C/C++ 8 |
70 |
Microsoft C 5 |
70 |
Borland Turbo C 2 |
64 |
HI-TECH Pacific C 7 |
56* |
Borland C++ 2 |
54* |
Microsoft QuickC 1 |
25* |
Mix Power C 2.2 |
*Tested in DOSBox only.
|
The individual results show some trading of places depending on the platform.
While third place was consistently held by Digital Mars
C/C++ 8, Visual C++ 1.5 was faster than Open Watcom C/C++ 1.9 on
older platforms but vice versa on newer ones; that being especially evident
when comparing between DOSBox and the Intel Xeon E3.
Individual results by platform
Platform |
Results* |
DOSBox |
FPS |
Compiler |
Command-line options |
57 |
Microsoft Visual C++ 1.5 |
/f-
/AL
/Ox
/G3
|
41 |
Digital Mars C/C++ 8 |
-mld
-a2
-5
-f
-o+speed
|
37 |
Open Watcom C/C++ 1.9 |
-bcl=dos
-ml
-oneatx
-oh
-ei
-zp2
-5
-fpi87
-fp5
-sg
-k16384
|
33 |
Borland Turbo C 2 |
-a
-1
-f87
-ml
-Z
-G
-O
|
32 |
Borland C++ 2 |
-a
-1
-f87
-ml
-Z
-G
-O
|
32 |
Microsoft C 5 |
/AL
/FPi87
/O
/G2
|
31 |
Microsoft QuickC 1 |
/AL
/FPi87
/O
/G2
/Gs
|
30 |
HI-TECH Pacific C 7 |
-2
-7
-AL16,16,4
-Bl
-Zg
|
14 |
Mix Power C 2.2 |
/2
/a
/e
/f87
/ml
|
|
Pentium 90 |
FPS |
Compiler |
Command-line options |
26 |
Microsoft Visual C++ 1.5 |
/f-
/AL
/Ox
/G3
|
26 |
Open Watcom C/C++ 1.9 |
-bcl=dos
-ml
-oneatx
-oh
-ei
-zp2
-5
-fpi87
-fp5
-sg
-k16384
|
24 |
Digital Mars C/C++ 8 |
-mld
-a2
-5
-f
-o+speed
|
22 |
Microsoft C 5 |
/AL
/FPi87
/O
/G2
|
19 |
Borland Turbo C 2 |
-a
-1
-f87
-ml
-Z
-G
-O
|
17 |
HI-TECH Pacific C 7 |
-2
-7
-AL16,16,4
-Bl
-Zg
|
|
AMD K6-2 300 |
FPS |
Compiler |
Command-line options |
105 |
Open Watcom C/C++ 1.9 |
-bcl=dos
-ml
-oneatx
-oh
-ei
-zp2
-5
-fpi87
-fp5
-sg
-k16384
|
102 |
Microsoft Visual C++ 1.5 |
/f-
/AL
/Ox
/G3
|
95 |
Digital Mars C/C++ 8 |
-mld
-a2
-5
-f
-o+speed
|
78 |
Borland Turbo C 2 |
-a
-1
-f87
-ml
-Z
-G
-O
|
77 |
Microsoft C 5 |
/AL
/FPi87
/O
/G2
|
65 |
HI-TECH Pacific C 7 |
-2
-7
-AL16,16,4
-Bl
-Zg
|
|
Intel Xeon E3 |
FPS |
Compiler |
Command-line options |
364 |
Open Watcom C/C++ 1.9 |
-bcl=dos
-ml
-oneatx
-oh
-ei
-zp2
-5
-fpi87
-fp5
-sg
-k16384
|
318 |
Microsoft Visual C++ 1.5 |
/f-
/AL
/Ox
/G3
|
299 |
Digital Mars C/C++ 8 |
-mld
-a2
-5
-f
-o+speed
|
279 |
Borland Turbo C 2 |
-a
-1
-f87
-ml
-Z
-G
-O
|
274 |
HI-TECH Pacific C 7 |
-2
-7
-AL16,16,4
-Bl
-Zg
|
244 |
Microsoft C 5 |
/AL
/FPi87
/O
/G2
|
|
*Frames per second (FPS). Higher is better. |
For 32-bit Windows, I ran two benchmarks: a rasterizer and a path tracer.
The rasterizer benchmark was adopted from the one used
for DOS but with modifications to make it run on Windows.
(The Open Watcom C/C++ 1.9 compiler was supposed to be included in this benchmark, but
the executable it produced would always crash, so I left it out. I found out later
that the solution was to increase the stack size via a compiler flag. You'll find Win32
results with this compiler in the path tracer benchmark.)
The overall results show MinGW 4.7.1 in the lead, Digital Mars C/C++ 8 taking second
place, and Microsoft Visual C++ 6 coming in third.
Overall results for the Win32 rasterizer
Score (%) |
Compiler |
100 |
MinGW 4.7.1 |
86 |
Digital Mars C/C++ 8 |
78 |
Microsoft Visual C++ 6 |
67 |
Microsoft Visual C++ 7 (non-optimizing) |
58 |
Borland C++ 5.5 |
In the individual results, it's interesting to see the difference between the
non-optimizing Visual C++ 7 and the optimizing Visual C++ 6 compilers: the more
modern the platform, the better the optimizing compiler does.
Individual results by platform
Platform |
Results* |
AMD K6-2 300 |
FPS |
Compiler |
Command-line options |
156 |
MinGW 4.7.1 |
-O3
|
142 |
Digital Mars C/C++ 8 |
-mn
-a8
-5
-cpp
-c
-f
-o+speed
|
126 |
Microsoft Visual C++ 7 (non-opt.) |
Not available
|
119 |
Microsoft Visual C++ 6 |
Not available
|
118 |
Borland C++ 5.5 |
-5
-P
-f
-O2
-O
-tWC
|
|
AMD Athlon 64 |
FPS |
Compiler |
Command-line options |
1309 |
MinGW 4.7.1 |
-O3
|
1135 |
Digital Mars C/C++ 8 |
-mn
-a8
-5
-cpp
-c
-f
-o+speed
|
926 |
Microsoft Visual C++ 6 |
Not available
|
746 |
Borland C++ 5.5 |
-5
-P
-f
-O2
-O
-tWC
|
727 |
Microsoft Visual C++ 7 (non-opt.) |
Not available
|
|
Intel Xeon E3 |
FPS |
Compiler |
Command-line options |
8209 |
MinGW 4.7.1 |
-O3
|
7033 |
Microsoft Visual C++ 6 |
Not available
|
6690 |
Digital Mars C/C++ 8 |
-mn
-a8
-5
-cpp
-c
-f
-o+speed
|
5227 |
Microsoft Visual C++ 7 (non-opt.) |
Not available
|
3503 |
Borland C++ 5.5 |
-5
-P
-f
-O2
-O
-tWC
|
|
*Frames per second (FPS). Higher is better. |
The path tracing benchmark used the
smallpt path tracer with the
following settings:
Renderer settings for smallpt
Platform |
Resolution |
Samples per pixel |
AMD K6-2 300 |
40 × 30 |
512 |
AMD Athlon 64 |
40 × 30 |
2048 |
Intel Xeon E3 |
40 × 30 |
4096 |
The overall results indicate that MinGW 4.7.1 generated the fastest executable, followed
by those of Digital Mars C/C++ 8 and Open Watcom C/C++ 1.9. However, the one
by Digital Mars rendered only partially correctly, producing an unwanted white line at the
top of the image.
Overall results for the Win32 path tracer
Score (%) |
Compiler |
99 |
MinGW 4.7.1 |
82 |
Digital Mars C/C++ 8 |
63 |
Open Watcom C/C++ 1.9 |
56 |
Borland C++ 5.5 |
The individual results generally agree that MinGW 4.7.1 was the fastest across the board.
Although it seemed that Digital Mars C/C++ 8 was catching up on older platforms, it should
be noted again that the rendering its executable produced had artifacting.
Individual results by platform
Platform |
Results* |
AMD K6-2 300 |
Seconds |
Compiler |
Command-line options |
49 |
Digital Mars C/C++ 8 |
-mn
-a8
-5
-cpp
-c
-f
-o+speed
|
50 |
MinGW 4.7.1 |
-O3
|
55 |
Open Watcom C/C++ 1.9 |
-oneatx
-oh
-oi+
-ei
-zp8
-5
-fpi87
-fp5
|
62 |
Borland C++ 5.5 |
-5
-P
-f
-O2
-O
-tWC
|
|
AMD Athlon 64 |
Seconds |
Compiler |
Command-line options |
21 |
MinGW 4.7.1 |
-O3
|
30 |
Digital Mars C/C++ 8 |
-mn
-a8
-5
-cpp
-c
-f
-o+speed
|
38 |
Open Watcom C/C++ 1.9 |
-oneatx
-oh
-oi+
-ei
-zp8
-5
-fpi87
-fp5
|
43 |
Borland C++ 5.5 |
-5
-P
-f
-O2
-O
-tWC
|
|
Intel Xeon E3 |
Seconds |
Compiler |
Command-line options |
9 |
MinGW 4.7.1 |
-O3
|
12 |
Digital Mars C/C++ 8 |
-mn
-a8
-5
-cpp
-c
-f
-o+speed
|
20 |
Open Watcom C/C++ 1.9 |
-oneatx
-oh
-oi+
-ei
-zp8
-5
-fpi87
-fp5
|
22 |
Borland C++ 5.5 |
-5
-P
-f
-O2
-O
-tWC
|
|
*Seconds to render. Lower is better. |
For DOS, the most performant compiler was generally Open Watcom C/C++ 1.9 –
the caveat being that Microsoft Visual C++ 1.5 was noticeably faster in DOSBox, and
showed potential to be faster on pre-Pentium platforms in general. Out of
the pure C compilers, Borland Turbo C 2 and Microsoft C 5 were the top performers,
although some 20% slower than the two C/C++ compilers just mentioned.
For 32-bit Windows, MinGW 4.7.1 was essentially the most performant compiler
across the board and by a notable margin. Seeing as both Digital Mars C/C++ 8 and Open
Watcom C/C++ 1.9 – the two next-fastest compilers – had issues of one
kind or another, it's hard to recommend anything but the MinGW (of which version
4.7.1 should work with both Windows 95 and 98; later versions dropped support for 95).