Re: Why are intepreters so slow today

Mike Tibbs (tibbs@dopey.si.com)
Mon, 18 Apr 94 14:05 EDT

>
> >>> My basic test is to run something equivalent to
> >>>
> >>> int i; double x = 0.0;
> >>> for (i = 0; i < 1000000; i++) x = x + 1.0;
> >>
> >>I tried this on my machine, and also tried the equivalent code in
> >>Smalltalk/V for Win32:
> >>
> >>x := 0.0.
> >>1000000 timesRepeat: [x := x + 1.0]
> >>
> >>The C version, running in a DOS window under Windows 3.1, executed in
> >>about 4 seconds. The Smalltalk code ran in 14 seconds. That's a factor
> >>of between 1/3 and 1/4 the speed of the C version---Certainly within
> >>your criterion of 1/10.
>
> You can further improve on this:
>
> Just use a machine that is even slower on
> emulating floating point arithmetic. Then
> the factor will approach 1 ...
>
> When I compiled the C code on my Sparc, it took 0.076 seconds to run the C
> version. I'd guess that more than 3.5 of the 4 seconds it took your PC were
> spent in the FP emulation library. If you'd repeat the test on a 486DX2
> with a good C compiler, you'd probably get a time of 0.2 seconds for the C
> version and 5 to 10 seconds for the Smalltalk version.
>
> That's a factor of 1/25 to 1/50, your value of 1/3 is only possible by
> using a computer with slooow FP ...
>
> STefan

I ran the Smalltalk code above in ObjectWorks 4.0 on a Sparc10 model 20.
Just selecting "do it" while the code was highlighted took 2.8 seconds.
Now this method does not do any precompilation to byte code - it is pure
interpretation.

I had nearly the same result for the C version, *if* I used the -O flag
to optimize:

int main()
{
int i; double x = 0.0;
for (i = 0; i < 1000000; i++) x = x + 1.0;
}

tibbs} cc -O fptest -o fptest
tibbs} time fptest
0.100u 0.040s 0:00.09 155.5% 0+74k 0+0io 0pf+0w

So, Smalltalk is about 1/40 the speed of C for this _simple_ test.

This is by no means a benchmark of FP performance for these languages.
The time to do the loop, create temporary objects, are also variables
in the equation. (And let's not get into a programming language flame :)

- Apologies to the Python-ers for the lack of Python-relevant info.

== Mike Tibbs
== tibbs_michael@si.com
== 616-241-7572