Created
August 2, 2012 23:56
-
-
Save takikawa/3242280 to your computer and use it in GitHub Desktop.
call/cc vs. delim control speed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define pt (make-continuation-prompt-tag)) | |
(define (fact n) | |
(if (zero? n) | |
1 | |
(* n (fact (sub1 n))))) | |
(time | |
(for ([i 10000]) | |
(call-with-continuation-prompt | |
(lambda () | |
(call/cc | |
(lambda (k) | |
(k (fact 5))) | |
pt)) | |
pt))) | |
(time | |
(for ([i 10000]) | |
(call-with-continuation-prompt | |
(lambda () | |
(call-with-composable-continuation | |
(lambda (k) | |
(abort-current-continuation | |
pt | |
(lambda () (k (fact 5))))) | |
pt)) | |
pt))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment