Friday, May 21, 2010

I have a perl server script running that many times doing memcpy as shown from pstack. Where could it from?

Could it be from passing variables to a subroutine?


Is it more efficient to access the variable through $_[0] or shift?


I have to pass some text and arrays from one sub to another.

I have a perl server script running that many times doing memcpy as shown from pstack. Where could it from?
90% of what a program does it move data around.. that's memcpy.





shift is insignificantly slower than a single access to $_[0]


shift is insignificantly faster than multiple accesses.





it's probably not the little perl code that is doing the little thing, it's the database or io that is bogging down the server.





You need to profile your code, routine by routine... or hire a person who can look at code and see where you've gone wrong.





a "perl slinger"
Reply:I think what Jake is trying to say is, whether you use @_ or shift doesn't matter, because when your sub starts executing, perl has already made copies of the arguments. You should pass by reference to avoid any copies being made.





my $big_string;


my @array;


...


%26amp;function(\$big_string, \@array);


No comments:

Post a Comment