mgorlick / CRESTaceans

Experiments and documentation for building CREST infrastructure. This material is based upon work supported by the National Science Foundation under Grant No. 0820222.
http://www.isr.uci.edu/projects/crest/
5 stars 2 forks source link

use vectors for serializer data structure #2

Open kstrasser opened 13 years ago

kstrasser commented 13 years ago

The serializer must avoid using lists at all costs because they are about 7x more expensive time-wise to `write' and produce lots of extra garbage.

Test example: $ ./write.rkt "List trial: " cpu time: 1344 real time: 1345 gc time: 524 "Vector trial: " cpu time: 204 real time: 204 gc time: 0

! /usr/bin/env racket

lang racket/base

(require racket/list racket/vector) (print-graph #f)

(define l (make-list 1000000 1)) (define v (make-vector 1000000 1)) (define ol (open-output-bytes)) (define ov (open-output-bytes))

(collect-garbage) (collect-garbage) (collect-garbage) (collect-garbage)

"List trial: " (define wl (time (write l ol) (get-output-bytes ol)))

(collect-garbage) (collect-garbage) (collect-garbage) (collect-garbage)

"Vector trial: " (define wv (time (write v ov) (get-output-bytes ov)))