[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: email@example.com
- Subject: Mini benchmark.
- From: "John Carter" <ECE@dwaf-hri.pwv.gov.za>
- Date: Thu, 26 Oct 1995 09:14:55 +0200
- Organization: Dpt Water Affairs & Forestry (IWQS)
- Priority: normal
I am contemplating writing some largish programs in CLISP. But before
I commit myself to this I need a very rough idea of performance. I
have this pet little bench mark which calculates e=2.71828... I like
this benchmark because :-
1) It reflects floating point performance, (which I am
most concerned with).
2) It is dead simple. So simple it can be translated in 30 seconds
to any language you choose.
3) It cannot be optimised away entirely.
4) You can see immediately if you got the right answer.
Here it is in C or C++...
main( int argc, char * argv)
double x, y;
sscanf( argv[ 1], "%d", &n);
x = 1.0;
y = 1.0 + 1.0 / n;
for( int i=0; i < n; i++)
x *= y;
printf( "y=%lf, x=%lf\n", y, x);
Here it is QBasic...
INPUT "n?"; n
x = 1
y = 1 + 1 / n
FOR i = 1 TO n
x = x * y
PRINT "y="; y; " x="; x
Here it is in AWK...
x = 1.0
y = 1.0 + 1.0 / n
for( i=0; i<n; i++)
x *= y
print "y=", y, " x=", x
Here it is in Actor...
n := 100000L
y := 1.0 + 1.0 / n
x := 1.0
while n > 0
x := x * y;
n := n - 1;
print( " x=");
And finally, the point of this whole message, in Lisp...
(defun test (n)
(let ((x 1.0) (y (+ 1 (/ 1.0 n))))
(dotimes (i n)
(setf x (* x y)))
According to my tests I rank languages like so..
Interpreted Emacs lisp and Clisp
Awk, Actor and MS-Excel Visual Basic
Compiled EMACS Lisp
GNU C++ (33 times faster than Emacs lisp and 170x faster than Actor)
Now I may be doing something silly in Lisp (I'm not "at home" with
it), can the readers please rewrite the lisp code to run as fast as
possible. (All speed optimization flags on).
This may be a VERY VERY crude benchmark, but it gives a suprisingly
(given the crudeness) accurate reflection of the reality.
Institute for Water Quality Studies. Department of Water Affairs.
Internet : firstname.lastname@example.org Phone : 27-12-808-0374x194
Fax : 27-12-808-0338 [Host for Afwater list server]
Founder of the Council for Unnatural Scientists.