chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Good way to code the equivalent to this?


From: felix winkelmann
Subject: Re: [Chicken-users] Good way to code the equivalent to this?
Date: Sun, 24 Aug 2008 11:06:57 +0200

Hi!


This should perform much better and more closely
resembles what you are trying to achieve.

Note that Perl's data structures are bummed to absurd
dimensions. We don't want that.


cheers,
felix
--

(use extras)

(define a (make-hash-table equal?))

(print "filling ...")

(do ((i 0 (add1 i)))
    ((>= i 250000))
  (hash-table-set!
   a
   (cons (random 500000) (random 500000))
   #t))

(print "reading ...")

(do ((i 0 (add1 i))
     (hits 0))
    ((>= i 10000))
  (let ((x (random 500000))
        (y (random 500000)))
    (when (hash-table-ref/default a (cons x y) #f)
      (set! hits (add1 hits)))))

(print "done.")




reply via email to

[Prev in Thread] Current Thread [Next in Thread]