Re: Compiling file with many functions: huge performance difference between IDL and IDLDE [message #38647 is a reply to message #38531] |
Thu, 18 March 2004 12:36   |
Sidney Cadot
Messages: 7 Registered: October 2002
|
Junior Member |
|
|
Andrew Cool wrote:
> OK, me dumb bunny - me no know what a string based map is.
> But based on your example above, how about this?
>
> map_array = Strarr(12000,2)
>
> map_array(0,1) = string(indgen(12000),form='(i5.5)')
> map_array(5000,0) ='dick'
>
> t = Systime(1)
> found_index = Where(map_array(*,0) EQ 'dick')
> print,'Time taken = ',Systime(1) - t,' seconds'
> print,'Found Index = ',found_index
> ret_value = map_array(found_index,1)
> print,'Returned Value = ',ret_value
This uses a linear search. This is a lot slower than IDL's internal
hashing, which is basically O(1).
> Now on my PC, Time taken = 0.00000000 seconds,
> which I'd call pretty close to "optiomal".
Try calling it a million times and compare it to my solution; you will
see a significant difference.
> Do you really need 12000 function definitions?
I have yet to see a better solution.
Best regards,
Sidney
|
|
|