Think about Loose Coupling | |
PerlMonks |
Types of Efficiencyby David Caughell (Monk) |
on Feb 03, 2004 at 22:48 UTC ( [id://326342]=perlmeditation: print w/replies, xml ) | Need Help?? |
I've seen all kinds of code on perlmonks, and it appears to me that there are definitely different types of efficiency, when it comes to evaluating whether or not code is "good". To put it another way, I guess you could say that when it comes to efficiency: TMTOWTDI Though this topic has probably been discussed, I supersearched titles and didn't find that it was discussed in its own node (search:efficiency importan). I'm going to throw out a few ideas, and anyone who wants to add to this is encouraged. This is my amateur opinion, so if some professionals want to give their views, that would be great. Obviously, how long it takes a program to compile and execute (more importantly, to execute), is a good judgement of efficiency, in many situations. In other situations, your efficiency could be measured by how little memory is used, or how little storage is used, or how easily your peers understand your code, (they might not be perlmonks). Another measurement of efficiency is how long it takes you to write the code (trading machine time for programmer time). In node 326181 I wrote a script which when running a 733 or 750 AMD chip, took only a second or so to compile and execute. It produced output to a text file, within an accuracy that was customizeable within the program. I believe that in this case, the "efficiency" of this program is better judged as the speed of transfering the output (i.e. bandwidth) or how long it would take to find information in it using an editor / browser. This is mostly because it uses a small amount of processing power and because it only needs to be run once. (That being said, I titled the node "Percentage to Fractions", so it was good of them to post some efficient code in there, in case someone else looks for the same thing!) An argument in favour of making any script most efficient in the traditional sense is that one day the programmer will more than likely need to write something that runs fast, so they might as well learn how to as soon as possible. Maybe someone ought to make a node where people can post little tricks to make their programs compile faster.
Back to
Meditations
|
|