more useful options | |
PerlMonks |
Re^5: More efficient way to get uniq list elements from list of listsby Aighearach (Initiate) |
on Nov 11, 2004 at 23:01 UTC ( [id://407213]=note: print w/replies, xml ) | Need Help?? |
Maybe it is just semantics, but I don't think map is the same algorithm as for(;;){} at the language level. At a higher level, sure, but here we're only comparing Perl implementations, so I'm assuming "algorithm" at that level. Really I should have used a really big list for longrand, like a million elements or something. Because that was my intention, to show the scalability difference between correctly iterating over the arguments, whereas my results only hinted that there are scalability differences. Here they are with yours added and just a large data set, 1_000_000 this time. Note that we're takling about simonm() that was what you had posted, not this new simonm2() which is more of an improvement, and definately the best of the bunch. Here are my results with a 1_000_000x2 data set.
THe aighearach2 is my try, but with your map to populate the slice, as follows:
I find it interesting how the implementations start to really seperate from each other on larger data sets. I imagine that if they were run through Devel::DProf or something, it would be found that memory consumption is the big difference. If anybody is still following this thread, that would be interesting to see... Your results are a bit different than mine, perhaps because of the different platform. I guess it is the increment in aighearach2() that makes simonm2() 13%(!) faster An important lesson can be learned, I think, by studying closely the changes you made between simonm() and simonm2(). A good contrast between an anon hash that is used simplistically, and a named hash with it's full power unleashed. -- Snazzy tagline here
In Section
Seekers of Perl Wisdom
|
|