Path: utzoo!attcan!uunet!snorkelwacker!tut.cis.ohio-state.edu!att!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.eiffel Subject: Re: Benchmark article - Eiffel vs. C++ vs. Smalltalk-80 Keywords: benchmark, Eiffel, C++, performance Message-ID: <10617@alice.UUCP> Date: 23 Mar 90 18:58:55 GMT References: <274@eiffel.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 39 In article <274@eiffel.UUCP>, kimr@eiffel.UUCP (Kim Rochat) writes: > Note that Eiffel is just as fast as C++ on the Sun and faster than C++ > on the Tektronix workstation. This seems ironic since C++ is touted as > being efficient and the mosaic program exercises features which should > be efficiently implemented in C. I thought it would be interesting to see what could be done trivially to speed up the C++ version of this program, so I profiled it. My machine does not have the Berkeley random() function, so I substituted an equivalent function, nrand() from our local C library. I found the following front-runners: %time function 20 Row::contrastColorCanAppearAt 17 nrand 15 Row::subsequentRow 11 Row::contrastColor 10 mcount (the C profiler itself!) 10 Row::addRandomColorAt 8 Row::addBaseColorAt 3 Row::addContrastColorAt Of the six C++ functions shown here, four of them were so short that many C++ programmers would have written them as inline as a matter of routine, namely Row::contrastColor, Row::addRandomColorAt, Row::addBaseColorAt, and Row::addContrastColorAt. Row::subsequentRow was not called many times and Row::contrastColorCanAppearAt was fairly large, so inlining wouldn't help either of these much. With these trivial changes, the run time on my machine (a MicroVax II) went from 161 to 100 seconds (timed without profiling). Profiling the revised program showed 30% spent in nrand, which suggests that it would be hard to obtain further dramatic improvement without first obtaining a faster random number generator. -- --Andrew Koenig ark@europa.att.com