time -p racket fib.rkt 100000 | wc -c
real 0.66
user 0.59
sys 0.06
20900
Not too shabby considering typed/racket incurs quite an overhead. This is after compiling to bytecode.
raco make fib.rkt
#lang typed/racket | |
(: fib (-> Number Number)) | |
(define (fib n) | |
(fib-iter 0 1 n)) | |
(: fib-iter (-> Number Number Number Number)) | |
(define (fib-iter a b n) | |
(if (= n 0) a | |
(fib-iter b (+ a b) (- n 1)))) | |
(define nth (command-line #:args (#{nth : String}) (string->number nth))) | |
(if (number? nth) | |
(fib nth) | |
(displayln "Please provide a number as an argument.")) |
time -p racket fib.rkt 100000 | wc -c
real 0.66
user 0.59
sys 0.06
20900
Not too shabby considering typed/racket incurs quite an overhead. This is after compiling to bytecode.
raco make fib.rkt