[Larceny-users] Performance of List Based Data Structures With ERR5RS Recorcs
Ray Racine
ray.racine at gmail.com
Sun Sep 14 11:05:18 EDT 2008
Naively I did not expect this result in the sense of O(1) for vector-like
vs. O(n) of cons lists.
Records are almost 10x slower then cons lists.
(import (rnrs))
(import (err5rs records syntactic))
(import (primitives time))
(define-record-type rec
#t #t a b c d e)
'records
(time
(let ((r (make-rec 'a 'b 'c 'd 'e)))
(do ((i 10000000 (fx- i 1)))
((fxzero? i) (rec-e r))
(rec-a r)
(rec-b r)
(rec-c r)
(rec-d r)
(rec-e r))))
'lists
(time
(let ((data '(a b c d e)))
(do ((i 10000000 (fx- i 1)))
((fxzero? i) (cadr (cdddr data)))
(car data)
(cadr data)
(caddr data)
(cadddr data)
(cadr (cdddr data)))))
> records
> Words allocated: 0
Words reclaimed: 0
Elapsed time...: 1126 ms (User: 1126 ms; System: 0 ms)
Elapsed GC time: 0 ms (CPU: 0 in 0 collections.)
e
> lists
> Words allocated: 0
Words reclaimed: 0
Elapsed time...: 129 ms (User: 129 ms; System: 0 ms)
Elapsed GC time: 0 ms (CPU: 0 in 0 collections.)
e
>
Ray
-------------- next part --------------
HTML attachment scrubbed and removed
More information about the Larceny-users
mailing list