gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] Re: incf vs. +1


From: Camm Maguire
Subject: [Gcl-devel] Re: incf vs. +1
Date: 13 Apr 2006 20:03:11 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings, and thanks!

(incf x) goes to (let ((g 1)) (+ x g)), so the setq is effectively
(setq x (the fixnum (let ((g 1)) (+ x g)))).  Here, as we do not yet
hav reverse type propagation, the + appears to overflow the fixnum
range and proceeds more slowly.  Replacing fixnum with e.g. seqind
removes the issue.  But perhaps the best is to avoid the let binding
when the increment is constant.

Take care,

Robert Boyer <address@hidden> writes:

> I think that the following transcript shows that sometimes, incf is an order
> of magnitude slower than it can and ought to be.  No idea why.  Perhaps I
> just am uninformed about the meaning of incf.
> 
> Bob
> 
> -------------------------------------------------------------------------------
> GCL (GNU Common Lisp)  2.7.0 ANSI    Apr  1 2006 15:10:32
> >(defun foo () (let ((x 0)) (declare (fixnum x)) (loop while (< x 100000000) 
> >do (incf x))))
> FOO
> >(compile 'foo)
> NIL
> >(time (foo))
> real time       :      1.880 secs
> run-gbc time    :      1.880 secs
> child run time  :      0.000 secs
> gbc time        :      0.000 secs
> NIL
> >(defun foo () (let ((x 0)) (declare (fixnum x)) (loop while (< x 100000000) 
> >do (setq x (+ x 1)))))
> FOO
> >(compile 'foo)
> NIL
> >(time (foo))
> real time       :      0.110 secs
> run-gbc time    :      0.100 secs
> child run time  :      0.000 secs
> gbc time        :      0.000 secs
> NIL
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]