Linked by Christopher W. Cowell-Shah on Thu 8th Jan 2004 19:33 UTC
General Development This article discusses a small-scale benchmark test run on nine modern computer languages or variants: Java 1.3.1, Java 1.4.2, C compiled with gcc 3.3.1, Python 2.3.2, Python compiled with Psyco 1.1.1, and the four languages supported by Microsoft's Visual Studio .NET 2003 development environment: Visual Basic, Visual C#, Visual C++, and Visual J#. The benchmark tests arithmetic and trigonometric functions using a variety of data types, and also tests simple file I/O. All tests took place on a Pentium 4-based computer running Windows XP. Update: Delphi version of the benchmark here.
Permalink for comment
To read all comments associated with this story, please click here.
RE: Your C++ program is really just C!
by Arthur Dent on Fri 9th Jan 2004 10:56 UTC

"I don?t know C++. I taught myself just enough C (from an O?Reilly book) to code the benchmark. So yes, the C++ benchmark is running pure C code. From my rudimentary knowledge of C vs. C++, I assumed that there were no important extensions to C that would produce significantly different performance over straight C for low-level operations like this, so I stuck to straight C. I called it a ?Visual C++? benchmark because it was compiled by Microsoft?s C++ compiler. And if C++ really is a superset of C (please correct me if that?s not the case?I could be very wrong), then a C program is also a C++ program."

Yes, but that is a poor excuse. The C# benchmark uses a class, and the C++ class would have been pretty much the same, bar tha main function being external to the class.

You need to look at the "iostreams" C++ standard library header (you may find it as "iostreams.h" under some environments.) Look at the cout instance variable, and note that it completely replaces printf, as iostreams replaces stdio.

for example:

printf("my value %d", d);


cout << "my value " << d;

There is obviously some different code going on here, and there *will* be a different result, if only fractional.

There will be other things you could have done too.