Ada speed vs. C...

Richard A Hammond hammondr at sunroof.crd.ge.com
Wed Mar 14 02:45:11 AEST 1990


In article <8347 at hubcap.clemson.edu> wtwolfe at hubcap.clemson.edu (Bill Wolfe) writes:

Summary: Bill just reposted an article from  Gary Morris of Telesoft
which reported that the Dhrystone results for the Telesoft compiler on
a 16.67 Mhz 68020 based system beat out 4 C compilers on similar systems.
The results were reported in 1988 at the Tri-Ada conference.

As even Reinhold Weicker admits (posting to Usenet, also in Sigplan Notices):

1) Dhrystone uses only the "Pascal Subset" of Ada.

2) Ada runtime checks should be disabled for comparison to other languages!

3) There is some concern that string operations are over-represented,
   as HrDr Weicker notes: [ quoted from his posting of Feb 11, 1989]

It should be noted that this is a language-dependent issue:  Dhrystone was
first published in Ada, and with Ada or Pascal semantics, the time spent in
the string operations is, at least in all implementations known to me,
considerably smaller than in C.  In Ada and Pascal, assignment and comparison
of strings are operators defined in the language, and the upper bounds of the
strings occuring in Dhrystone are part of the type information known at
compilation time.  The compilers can therefore generate efficient inline code
whereas in C, the string operations must be expressed in terms of the C
library functions "strcpy" and "strcmp".  (This is probably the main reason
why on most systems known to me, the Ada and Pascal version are faster than
the C version.)

I admit that the string comparison in Dhrystone terminates later (after
scanning 20 characters) than most string comparisons in real programs.  For
consistency with the original benchmark, I didn't change the program despite
this weakness.

-- END QUOTE --

So, while it is nice to see that Ada compilers can do as well as or better than
C, be aware of the conditions of the test and be sure that you understand
what the benchmarks measure.  In particular, I'd suggest getting
the number for the runtime checks enabled run, since that
should be the way you actually run Ada programs.

Rich Hammond



More information about the Comp.lang.c mailing list