in reply to Re^2: Matching First Character of Strings Efficiently (benchmarking)
in thread Matching First Character of Strings Efficiently
But I still consider such nano-optimization games to be more a waste than of value.Rate ... hb1 46.5/s ... ... tye2 181/s ...
Since when is a 4-to-1 speed-up "nano"? Granted, in the OP's case, maybe this particular 4:1 ratio would end up affecting only 10% of the overall run-time, once "expensive_process" (whatever it is) plays its role. Also, I wouldn't really want to bust my butt running an exhaustive test of 12 alternatives -- just compare the first (or current) idea against the next idea that looks like it could do better, in case the current idea seems to be taking longer than I like.
But given that this sort of vetting task is likely to come up, if I had to do it over an input list of, say, 2 million items, I'd much prefer that it take 3 hours rather than 12.
update: Having seen the replies to my post from tye and Aristotle, I have to say (sheepishly) thanks for the wake-up -- I should have known better than to take this sort of benchmark tabulation at "face value". In fact, I have used Benchmark myself on other problems -- but I opted for the "timethese" method (not "cmpthese"), which offers the advantage of showing the overall wall-clock difference as well as the "relative proportional" time difference for each approach. In one attempt, a comparison of two approaches showed "5.44/s" for one and "94.34/s" for the other -- like wow, huh? -- but the wall-clock difference was 2 sec vs. 9 sec... go figure. If an app really needs to be optimized, the first tool of choice should be profiling, of course, to see what segment of the code is eating all the time, so you can rethink that part first.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Matching First Character of Strings Efficiently (4 times!)
by tye (Sage) on Mar 16, 2004 at 02:21 UTC | |
|
Re^4: Matching First Character of Strings Efficiently (benchmarking)
by Aristotle (Chancellor) on Mar 16, 2004 at 03:21 UTC |