[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
continuation benchmark patch
From: |
Lynn Winebarger |
Subject: |
continuation benchmark patch |
Date: |
Sat, 24 Aug 2002 10:25:33 -0500 |
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))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- continuation benchmark patch,
Lynn Winebarger <=