I ran across the snippet of code below (I turned it into a performance
benchmark) and was amazed at how much slower the code ran after making it
readable with dict!: I am seeing a factor of 20x and 40x depending on what
exactly is run. Can anything be done about this?
#lang racket
(define (create n)
(define i 0)
(define sample (make-vector n))
(lambda (item)
(set! i (+ i 1))
(vector-set! sample (if (<= i n) (sub1 i) (quotient n 2)) item)
sample))
(define counts (make-vector 10 0))
(define-syntax-rule
(measure n d update)
(begin
(collect-garbage)
(collect-garbage)
(collect-garbage)
(time
(for ([i n])
(define f (create 3))
(define sample (for/last ([digit 10]) (f digit)))
(for ([d sample])
update)))))
;; I don't want more HO overhead
(define n 1000000)
(measure n d (vector-set! counts d (add1 (vector-ref counts d))))
(measure n d (dict-update! counts d add1))
--
You received this message because you are subscribed to the Google Groups
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-dev/62F7A4E7-4AA2-4F73-9686-C84F2FF52CF7%40ccs.neu.edu.
For more options, visit https://groups.google.com/d/optout.