in reply to Re: it takes 1-2 seconds to return a string from a subrountine
in thread it takes 1-2 seconds to return a string from a subrountine

The problem is because I have two heavy processes for loading storable data inside the subrountine. After I moved those two out from the subrountine. The problem brothered me is gone. I guess that it is related to system memory swrap and memory allocation . I am sorry for not providing enough information earlier. Thanks a lot!
use Storable( retrieve, store) my $string = getString($ARGV[]); ENDING MY TIMER sub getString{ my ($file1, $file2) = @_; my @thisarray = @{retrieve($file1)}; # size ~ 20M my %thishash = %{retrieve($file2)}; # size ~ 5M my $thisString; # here I am doing something # to create a $thisString and its size is less than 100K STARTING MY TIMER return $thisString; }
  • Comment on Re: Re: it takes 1-2 seconds to return a string from a subrountine
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: it takes 1-2 seconds to return a string from a subrountine
by runrig (Abbot) on Aug 14, 2002 at 18:03 UTC
    You may save alot of memory (and perhaps time) if you can avoid dereferencing the large array and hash refs. Don't dereference and assign them to the array and hash; just leave them as references.