[rescue] Mainframe on eBay

Charles Shannon Hendrix shannon at widomaker.com
Fri Sep 30 11:17:45 CDT 2005


Thu, 22 Sep 2005 @ 19:24 +0000, Peter said:

> "Programmer time is more expensive than computer time"

This is only occasionally true.  It's one of the worst rules of thumb in
the industry though, because of how often it isn't true.

> "Optimise for reduced latency over increased throughput"

...and get fired because throughput was what was needed.

Shouldn't you first determine which is more important?

> "Don't consider optimising anything until you're used a profiler"

...and if you don't have a profiler?

...and if problems in the algorithm are obvious without testing?

For example, are you saying you would not optimize this code without
using a profiler first?

    int funky(int loopy) {
	char *buf;
	int i;
	for(i=0;i<loopy;i++) {
	    buf = malloc(1000000);
	    /* do stuff with buf */
	    free(buf);
	}
    }

Given it takes all of fives seconds to reduce the redundant buffer
creation to a single event, do you really need to profile first?

BTW, I see this kind of code *ALL* the time.  Here is the other common
one:

    char * stacky(void) {
	char buf[1000000];
	/* put stuff in buf */
	return buf;
    }

GNU C gives a warning, but some compilers say nothing.  Sometimes the
code will even work for awhile...

> "Don't optimise anything that you're not reducing the algorithmic
> complexity of"

It's a good general rule, but don't get trapped by it in situations
where the algorithm complexity is not the primary problem.

> "Don't use C when Perl will do"

That's about as absurd as "don't use 1 byte when 1 billion will do."

I'd say the real answer is that it depends on what you are doing.

-- 
shannon "AT" widomaker.com -- ["There is no such thing as security.  Life
is either bold adventure, or it is nothing -- Helen Keller"]



More information about the rescue mailing list