Wow, thanks. That cut my run time in half to aprox 8..4 seconds. I'm using chicken 2.74 on this machine. I've tried 3.3 at a different machine but not seen much difference.
Note that changing to non-hierarchical hashes breaks a lot of my existing code and is not exactly apples to apples with the perl. Still useful though and I may be able to use that approach with a little foresight next time. On Sun, Aug 24, 2008 at 9:36 PM, Alex Shinn <[EMAIL PROTECTED]> wrote: >>>>>> "Matt" == Matt Welland <[EMAIL PROTECTED]> writes: > > Matt> chicken: ~16 secs (when it didn't crash) > Matt> stk: ~17 secs > Matt> ruby: ~1.3 secs > Matt> perl: ~0.7 secs > > Which Chicken version are you timing, and with what compiler > optimizations? If you use -Ob and a suitable initial heap > size, then on my machine elf's version runs in under 700ms, > as opposed to ~500ms for the Perl version. Use the command: > > $ csc -Ob -heap-initial-size 300M file.scm > > If you really just want to get the job done regardless of > method, you can note that in this particular case a simple > vector is suitable and skip the hash tables altogether. > > This is over twice as fast as the perl version: > > ------------------------------------------------------------------------ > (define a (make-vector 500000 '())) > > (print "filling ...") > > (do ((i 0 (add1 i))) > ((>= i 250000)) > (let ((x (random 500000)) > (y (random 500000))) > (vector-set! a x (cons y (vector-ref a x))))) > > (print "reading ...") > > (define hits 0) > > (do ((i 0 (add1 i))) > ((>= i 10000)) > (let ((x (random 500000)) > (y (random 500000))) > (if (memq y (vector-ref a x)) > (set! hits (add1 hits))))) > > (print "done.") > ------------------------------------------------------------------------ > > > -- > Alex > _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
