Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Optimization Tale Plus Question
kvarnerexpress
post Jan 11 2006, 09:34 PM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



Just figured I'd post this real quick as I found the experience fairly amusing.

I was working on some code last week that, when I applied it to the full set of data, took about 1 hour and 10 minutes to run. Needless to say, this is quite slow, however I was using unoptimized code. I went for correctness first. Anyway, the first thing I noticed was that I could eliminate a good deal of array copying. I fixed that and it cut the time down to 23 minutes. This is still a lot slower than I wanted, so I went back to trying to optimize the code. After trying various things and researching some different things to optimize in Perl, I tried something completely and utterly stupid: I changed push to unshift. Now, I could do this since I was sorting the array later anyway, so ordering did not matter at this point.

Did it work? The code ran in 34 seconds. I must say, I was quite shocked by this. This leads me to my question: what's the difference between push and unshift in terms of how they work? I know they put data on different sides of the array. I'm just wondering why that made such a profound performance difference.
Go to the top of the page
 
+Quote Post
kvkv
post Feb 5 2006, 08:51 AM
Post #2


Newbie [Level 3]
***

Group: Members
Posts: 40
Joined: 29-January 06
Member No.: 17,841



That is a bit shocking because internally perl manages arrays as lists. And push() and unshift() are almost the same when it comes to performance. Are you sure you are dealing with the same set of data and haven't changed anything else? Can you post a code snippet that I can look into?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Multilingual Search Engine Optimization(2)
  2. Website Optimization Help(0)
  3. Web War(8)
  4. Secrets To Getting To The Top Of Google(45)
  5. Search Engine Optimization Tools(11)
  6. Google Optimization For Drupal(0)
  7. Css Resolution Optimization(6)
  8. Free Seo(2)
  9. Free E-gold Games Scripts(1)
  10. How To Perform Search Engine Optimization(8)
  11. Image Optimization?(6)
  12. All You Need For Seo (search Engine Optimization)(2)
  13. Good Way To Get Ranked In Google(30)
  14. Adsense Optimization(4)
  15. Help With A Css Design(8)
  1. Optimization Software(28)
  2. Google Search Engine Optimization(3)
  3. Html Advertising Optimization(0)
  4. Shark Tale ?(9)


 



- Lo-Fi Version Time is now: 6th September 2008 - 06:10 AM