[racket] performance tuning summing a hash of vectors

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Mar 13 12:34:52 EDT 2012

On Mar 13, 2012, at 12:05 PM, Marijn wrote:

> (define (sum-hash-of-vectors3 table keys size)
>  (apply vector-map +
> 	 (for/list ((k keys))
> 		   (hash-ref table k))))

Aren't the last two lines just 

   (hash-map table (lambda (key table) table)) 

;; -------------------------------------------

When it comes to performance, always try to trust the compiler first. 
It was eons ago that we had much intuition of how to turn code into
machine instructions, and how much these instructions would cost. This
is even true for C now (think pipelines, memory hierarchies, etc). 

Posted on the users mailing list.