Re: time wasters for 9grid
[email protected] Sat, 20 Dec 2003 21:19:38 +0000 (UTC)
| Newsgroups | gmane.os.plan9.nine-grid |
|---|---|
| Message-ID | <[email protected]> |
> People still think that function calls are expensive and they don't > profile their code (or don't get instruction counts) to find out where > the time is going. my favourite example of this was some years ago when someone came to me wondering why the imap code was taking more than a minute to read their 160K mail box. part of the code contained a 160 line macro (!), epitomising many of the evils of premature optimisation and non-portable coding, full of idioms like: if(*(int*)x[i] ==0x6d6f7266 with an 40 line comment attached along the lines of "so you actually want to try to understand this macro?!". anyway, after a bit of delving, most of the macro was replaced with a strstr(x, "from") and the runtime went from 100s down to 2s. wonderful stuff, free software.