From: Lynn Winebarger <owinebar@free-expression.org>
Subject: continuation benchmark patch
Date: Sat, 24 Aug 2002 10:25:33 -0500 [thread overview]
Message-ID: <02082410253310.19624@locke.free-expression.org> (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
reply other threads:[~2002-08-24 15:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=02082410253310.19624@locke.free-expression.org \
--to=owinebar@free-expression.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).