From: Brian Candler Date: 2003-05-26T21:11:59+09:00 Subject: Re: Binary Tree vs. Hash On Mon, May 26, 2003 at 06:29:23PM +0900, Xiangrong Fang wrote: > I have no good way to measure this. What I did is to watch the *total* > memory required by the program, with or without the hash. I don't know > if there is a way to do what you mentioned. May be some ruby experts > know? You are probably creating a lot of temporary garbage objects, so you're measuring the size of hash + garbage pool. You could try 'GC.start' to do garbage collection, but I don't know if Ruby then un-mallocs the storage and returns it to the O/S. > In my program lookup is very freqent, but update is rare. I tried using > Array.include? , but it seems is using seqential search, not binary. The > performance is unbearable. Does anyone know if ruby's internal > Array.include? is using binary search or not? It doesn't, because Array doesn't have any requirement to be sorted. Regards, Brian.