* continuation benchmark patch
@ 2002-08-24 15:25 Lynn Winebarger
0 siblings, 0 replies; only message in thread
From: Lynn Winebarger @ 2002-08-24 15:25 UTC (permalink / raw)
I've added a use of continuations where the scheme program
actually uses some stack space, and returns from the same
continuation multiple times. Possibly should change use-stack
to use + instead of cons.
The code is pretty ham-handed.
Lynn
Index: continuations.bm
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/benchmark-suite/benchmarks/continuations.bm,v
retrieving revision 1.1
diff -c -r1.1 continuations.bm
*** continuations.bm 20 Jul 2002 01:21:36 -0000 1.1
--- continuations.bm 24 Aug 2002 15:08:59 -0000
***************
*** 1,5 ****
(define (callee continuation)
(continuation #t))
! (benchmark "call/cc" 300
(call-with-current-continuation callee))
--- 1,53 ----
(define (callee continuation)
(continuation #t))
! (define call/cc call-with-current-continuation)
!
! (define use-stack
! (lambda (c escape)
! (if (<= c 0)
! (let ((deja-vu #f))
! (let ((tmp (call/cc (lambda (k) k))))
! (if deja-vu
! '()
! (begin
! (set! deja-vu tmp)
! (escape tmp)))))
! (cons c (use-stack (- c 1) escape)))))
!
! (benchmark "call/cc" 100
(call-with-current-continuation callee))
+
+ (benchmark "call/cc with stack - creation only" 100
+ (let ((k1 #f)
+ (k2 #f)
+ (i 100)
+ (a '()))
+ (let ((v (call/cc (lambda (k) k))))
+ (if (and k1 (not k2)) ;;; the second return to v should be with a continuation from use-stack
+ (set! k2 v))
+ (if (not k1) ;;; this is the basic continuation that sets v
+ (set! k1 v))
+ (if k2
+ v ;;; should never return here
+ (let ((v (use-stack 250 k1)))
+ v)))))
+
+
+ (benchmark "call/cc with stack creation + 100 calls" 100
+ (let ((k1 #f)
+ (k2 #f)
+ (i 100)
+ (a '()))
+ (let ((v (call/cc (lambda (k) k))))
+ (if (and k1 (not k2)) ;;; the second return to v should be with a continuation from use-stack
+ (set! k2 v))
+ (if (not k1) ;;; this is the basic continuation that sets v
+ (set! k1 v))
+ (if k2 (k2 #f)) ;;; should never return here
+ (let ((v (use-stack 250 k1)))
+ (set! a (cons v a))
+ (set! i (- i 1))
+ (if (<= i 0)
+ a
+ (k2 #f))))))
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-08-24 15:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-24 15:25 continuation benchmark patch Lynn Winebarger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).