[comp.lang.c++] Benchmark article - Eiffel vs. C++ vs. Smalltalk-80

jjc@jclark.UUCP (James Clark) (03/23/90)

In article <274@eiffel.UUCP>, kimr@eiffel.UUCP (Kim Rochat) presents
implementations of a small program in Eiffel, C++ and Smalltalk-80,
compares the performance of the implementations, and concludes
(amongst other things) that

  any perception that C++ has superior performance to Eiffel may
  be invalid.

It appears to me that the comparison between C++ and Eiffel is
vitiated by a failure to make any use of inline functions in the C++
version of the program.

I modified the C++ version of the program to make use of inline
functions.  I compared the original version of the program against the
version which used inlining. I also compared it with another version
which additionally replaced the heavily used random() function by a
simple inline random number generator. As well as declaring functions
inline, it was necessary to reorder the function definitions and to
make a cosmetic change to one function to work around a limitation in
cfront's inlining capabilities.

I performed the comparison on a Sun 4/370 and on a 386 PC. On the Sun
4 I used both cfront 2.0 and g++ 1.37.1; I found no measurable
difference in performance. On the 386 I used only g++ 1.37.1.  Also on
the 386 I used a 700 by 700 pattern, since the machine had only 4M of
RAM, and the 1000 by 1000 pattern caused it to thrash.

			User	Sys	Real
Sun 4, w/o inline	5.8	.7	6.6 
Sun 4, with inline	4.7	.6	5.4
Sun 4, with inline &	3.8	.6	4.6
  inline random()

386, w/o inline		12.5	.6	13.4
386, with inline	6.4	.6	7.3
386, with inline &	5.8	.6	6.7
  inline random()

The use of inline also resulted in a small decrease in the size of the
executables.

I should be glad to provide the modified version of the program to
anybody who wants it.

James Clark
jjc@jclark.uucp