I didn’t quite understand your long version. Are you saying that 

 ** on your specific machine ** 

Haskell’s “worst” is 50ms, OCaml is 3ms, and Racket’s is 120ms? 

FWIW, I can’t imagine Haskell code using set! for this benchmark, 
so I rewrote it in the obvious way (think monad). On my little laptop, 
the “worst” display went down by 25%. 




#lang racket/base

(define window-size 200000)
(define msg-count 1000000)

(define get-time current-inexact-milliseconds)
(define (message n)
  (make-string 1024 (integer->char (modulo n 256))))

(define (push-msg chan id-high worst)
  (define before (get-time))
  (define id-low (id-high . - . window-size))
  (define added  (hash-set chan id-high (message id-high)))
  (define result (if (id-low . < . 0) added (hash-remove added id-low)))
  (define after  (get-time))
  (define duration (after . - . before))
  (values result (max worst duration)))

(define-values (_ worst)
 (for/fold
     ([chan (make-immutable-hash)]
      [worst 0.0])
     ([i (in-range msg-count)])
   (push-msg chan i worst)))
(displayln worst)

-- 
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/BAACF1B3-AA19-4794-9C60-D33F1B7B14C2%40ccs.neu.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to