Ok, I just ran some tests to see the difference of calling code from a 'load' and an 'include'. I'm a bit confused. The tests with the loadable module were actually faster then the test that included the code. Can someone explain this?
--- util.scm (package* util/v1.0.0 (provide: (define* (getattr name alist _)))
(maintainer: "James Long <james at coptix.com>") (author: "James Long <james at coptix.com>") (homepage: "http://smallnum.blogspot.com") (description: "Utility") (keywords: flow))
(define* (getattr alist name (default #f)) (let ((r (assq name alist))) (if r (cdr r) default)))
--- moduletest.scm (package* moduletest/v1.0.0 (require: util/v1.0.0))
(define lst '((name . "James")))
(define (start n i) (if (< n i) (let* ((name (getattr lst 'name)) (chr (string-ref name 0))) (start (+ n 1) i))))
(start 0 10000000)
When the 'util' package is compiled inline (it uses "include"):
% time ./moduletest ./moduletest 2.38s user 0.04s system 90% cpu 2.655 total % time ./moduletest ./moduletest 2.36s user 0.02s system 98% cpu 2.418 total
And when the 'util' package is loaded in with 'load':
% time ./moduletest ./moduletest 2.00s user 0.03s system 90% cpu 2.252 total % time ./moduletest ./moduletest 1.99s user 0.02s system 99% cpu 2.029 total
I'm sure that I misunderstand the difference of 'load' and 'include', and I would be happy if someone could shed some light for me. I found a couple useful posts in the archive but not much. (I'm on OS X, macbook pro, with gambit v4.0)
On 9/2/07, James Long longster@gmail.com wrote: ...