thanks gabor, that was very insightful (i was about to suggest running two loops and testing them, but i must agree that that the effort is in the wrong direction.) ---
Besides the only place on Earth where a queue is implemented with unshift is Israel. "Just asking a question". :-D :-D 2009/3/26 Gabor Szabo <[email protected]>: > On Thu, Mar 26, 2009 at 11:13 AM, Berler Chanan <[email protected]> wrote: >> Hi All, >> >> I have a set of SQL needed to be run using timestamp field. >> I have created an array and needs to push / unshift the SQL statements into >> it for future execution >> (different conditions builds different set of SQL statements). >> >> I am using unshift to push the values into an array, so I will have the >> correct order, but I wonder >> if it is best to use push and reverse functions instead. >> >> Can anyone direct me to performance of unshift vs. push&reverse ? or >> push&pop ? >> Thanks >> Chanan >> > > Why do you care? > Please answer the following questions in order: > > Does your code do what it has to do? > Is the code clear to your satisfaction? > Is there a performance issue ? > Have you profiled the code checking where is the performance issue? > Is the performance issue in the code that adds the SQL statements. > > Then ask the above question. > > BTW You are writing "I am using unshift to push the values" which > would indicate > me that you are using the incorrect method. If you talk about pushing > values then > use that keyword it makes much more sense. > > Besides the only place on Earth where a queue is implemented > with unshift is Israel. "Just asking a question". > (ok, not really) > > Gabor > ps. push should be way faster than unshift but I am quite sure it does not > matter in your code. If you want to check, benchmark them. > _______________________________________________ > Perl mailing list > [email protected] > http://mail.perl.org.il/mailman/listinfo/perl > -- -- vish _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
