Re: response time problem.

Frederick Cheung
Sat, 22 Mar 2008 22:02:58 -0000

> --->         params[:selectedLandmark].each { |itr|
>           @selectedLandmarkList += @availLandmarkList.select{ |v|
> (v[1].to_s==itr)? true : false }
>         }
>       else ....
>
> If I get rid of the iterator which basically doesn''t do much, the
> response time is fast as the second list is empty. I don''t
understand
> why it is slow in the first case.

Well you may not think you''re doin very much but for each thing
selectedLandmar you''re iterating over availLandmarkList once, so if
these are both 9000 items long then you''re ending up doing something
81 million times. But whatever the reason is, the real answer is to
stop guessing and use a profiler (eg ruby-prof) to find out where the
time is going.

Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com