1 Aug 2011 19:36
Re: About peformance of user defined procedures
Jörg F. Wittenberger <Joerg.Wittenberger <at> softeyes.net>
2011-08-01 17:36:06 GMT
2011-08-01 17:36:06 GMT
just a wild guess:
On Jul 31 2011, Pedro Henrique Antunes de Oliveira wrote:
>Hey.
>
>I have a file map.scm, which contais this code:
>
>(define (mymap1 op ls)
> (let loop ((ls ls) (acc '()))
> (if (null? ls)
> (reverse acc)
> (loop (cdr ls) (cons (op (car ls)) acc)))))
^^^^
This compiles (*probably* and depending on optimisation switches you pass
to the compiler) one call equivalend to (procedure? op).
Since everything around is zero-effort, you basically check loop and
call performance here.
You might also find it funny to try:
(define (mymap1b op ls)
(let loop ((op op) (ls ls) (acc '()))
(if (null? ls)
(reverse acc)
(loop op (cdr ls) (cons (op (car ls)) acc)))))
which would avoid one indirection per call at the expense of
yet another loop parameter. Please let me know how much of a difference
(Continue reading)
RSS Feed