[Openmcl-devel] tagbody and go

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Wed Dec 8 09:58:49 PST 2010


I run the following test to show that ecase is not jumping directly
to the given step (less efficient then (go step)):

(defmacro gostep (step)
    `(block nil (tagbody (go ,step)
,@(loop for i = 0 then (1+ i)
    while (< i 100)
     append `(,i (return-from nil ,i) (go end)))
end)))

(defmacro define-runstep ()
    `(defun runstep (step)
(block nil
  (ecase step
,@(loop for i = 0 then (1+ i)
    while (< i 100)
     collect `(,i (return-from nil ,i)))
))))

(define-runstep)

? (time (dotimes (i 10000000) (gostep 99)))
(DOTIMES (I 10000000) (GOSTEP 99)) took 30 milliseconds (0.030 seconds) to
run
                    with 2 available CPU cores.
During that period, 30 milliseconds (0.030 seconds) were spent in user mode
                    0 milliseconds (0.000 seconds) were spent in system mode
NIL
? (time (dotimes (i 10000000) (runstep 99)))
(DOTIMES (I 10000000) (RUNSTEP 99)) took 988 milliseconds (0.988 seconds) to
run
                    with 2 available CPU cores.
During that period, 986 milliseconds (0.986 seconds) were spent in user mode
                    0 milliseconds (0.000 seconds) were spent in system mode
NIL


-Taoufik

On Wed, Dec 8, 2010 at 6:11 PM, Alexander Repenning
<ralex at cs.colorado.edu>wrote:

>
> On Dec 8, 2010, at 9:52 AM, Taoufik Dachraoui wrote:
>
> > It is not exactly what I am looking for, I would like to jump directly to
> the step.
> > The ecase will check all the clauses in order (like cond) until it finds
> a match.
>
>
> duno what CCL does in this particular case but most compilers could
> generate a jump and would not have to test all the previous clauses. In
> other words this is an implementation question.
>
> alex
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20101208/f21285de/attachment.htm>


More information about the Openmcl-devel mailing list