Changes http://wiki.axiom-developer.org/363ASlowSummation/diff
--
??changed:
-**On 6/13/07, Alasdair McAndrew wrote:**
+**On 6/13/07, Alasdair !McAndrew wrote:**
++added:
+
+**On 6/16/07, Waldek Hebisch wrote:**
+
+Bill Page wrote:::
+
+ > On 6/15/07, Waldek Hebisch wrote:
+ > > On my machine, I get the following (on the second run, to
+ > > exclude time for loading):
+ > >
+ > > gcl sbcl sbcl
+ > > interpreted compiled
+ > > reduce(+,[1.0/i for i in 1..20000]) 8.70 1.76 0.17
+ > > [i for i in 1..20000]; 6.23 0.78 0.01
+ > > expand(1..20000); 0 0.004 0.01
+ > >
+ >
+ > Waldek, thank you very much for running this comparison!
+ >
+ > So, the conclusion might be that I was wrong: the slowness *is*
+ > because of the way that Axiom interpreter runs this code in
+ > interpreted mode in GCL, right? It could still be that this interpreted
+ > Lisp code is not written in an optimal manner.
+ >
+
+As I wrote, it turned out that GCL interpreter is quite fast. After
+using modified LIST2VEC function (patch below, applied to wh-sandbox),
+
+I get the following timings::
+
+ reduce(+,[1.0/i for i in 1..20000]) 0.69
+ [i for i in 1..20000]; 0.09
+
+It seems that now significant part of execution time goes into
+floating point arithmetic.
+
+\begin{lisp}
+(defun LIST2VEC (list)
+ (if (consp list)
+ (let* ((len (length list))
+ (vec (make-array len)))
+ (dotimes (i len)
+ (setf (aref vec i) (pop list)))
+ vec)
+ (coerce list 'vector)))
+
+(define-function 'LIST2REFVEC #'LIST2VEC)
+\end{lisp}
+
+\begin{axiom}
+reduce(+,[1.0/i for i in 1..20000])
+[i for i in 1..20000];
+\end{axiom}
+
--
forwarded from http://wiki.axiom-developer.org/[EMAIL PROTECTED]