From: Tim P. <ti...@ho...> - 2001-01-13 18:29:05
|
[attribution lost] > HP: > > JPython 1.1+09 on java1.2.2.05 (JIT: null) > 86.5 <-- interpretted, very slow > > JPython 1.1+09 on java1.2.2.05 (JIT: HP) > 11.8 <-- classic JIT > > JPython 1.1+09 on java1.2.2.05 (JIT: null) > 14.9 <-- HotSpot JIT [Finn Bock] > My numbers are on Win2k & JDK1.3 & 300Mhz P3: > > Jython 2.0beta2 on java1.3.0 (JIT: null) > 37.74500000476837 <-- interpretted > > Jython 2.0beta2 on java1.3.0 (JIT: null) > 4.736999988555908 <-- hotspot > > While somewhat faster then your HP it is in the within the same range. [AL] > Linux 512 MHz dual Celeron (brain dead?) Pentium > > Linux: /home/mudd[1] jpython > JPython 1.1 on java1.2.2-RC2 (JIT: javacomp) > Copyright (C) 1997-1999 Corporation for National Research Initiatives > >>> from time import time > >>> t1=time(); x=2L**10000; delay=time()-t1; print delay > 0.00499 <-- About 2,400 times faster than HP's best numbers??!? > >>> [FB] > That's fast! Does it actually calculate the correct value? > > The power calculation is done fully by the java.math.BigInteger > implementation. The BigInteger.pow() on JDK1.3 (and HP too I > expect) is implemented in java as some kind of loop which I > don't understand. > > If the linux JVM are doing its BigInteger stuff in native code, that > might explain the difference. Let's try it under CPython on a Pentium box (866MHz P3 here): >>> t1=clock(); x= 2L**10000; delay=clock()-t1; print delay 0.00165775490706 >>> So that's how fast a good (but not optimal) pow runs: the Linux number is plausible. The obvious way to implement m**n is to do O(n) multiplications. A much smarter way (which CPython implements) uses only O(log2(n)) multiplications. For n==10000, n/log2(n) is very roughly about 1000. That's in the right ballpark for explaining a factor-of-2400 difference, which latter is very hard to explain otherwise. all-answers-are-in-the-source-code<wink>-ly y'rs - tim |