Skip to content

Instantly share code, notes, and snippets.

@takikawa
Created August 2, 2012 23:56
Show Gist options
  • Save takikawa/3242280 to your computer and use it in GitHub Desktop.
Save takikawa/3242280 to your computer and use it in GitHub Desktop.
call/cc vs. delim control speed
#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