B
blmblm
[snip]
Micro-optimisation is a nasty sin.
Yeah, yeah .... I guess it just seems strange to me that you went to
all the trouble of writing code to benchmark various approaches --
suggesting that sometimes you *do* engage in micro-optimization --
but are resistant to trying one more approach that (in my tests
anyway) sometimes reduced execution time by almost 50%. Just sayin',
"whatever", .... ?
It should be obvious to you why someone might do that.
The part that I was benchmarking is critical to my program. It
is repeatedly used since it is called for every non-newline character
in a file. Initialising a set of characters does not happen nearly so
often.
I know I don't always express myself with 100% clarity, but really,
I must be doing worse than usual here ....
I did not attempt to measure speed of initialization. That would
indeed be silly, and I don't understand why you would think ....
Well, be that as it may:
What I did was add to your benchmark code a test for LinkedHashSet,
identical to the one for TreeSet except for the type of set. When
I ran the resulting code, the output indicated that LinkedHashSet
was sufficiently faster than TreeSet for me to think you might
be interested. "Faster" here means "faster by your criterion as
I understand it". If you've made a decision and want to stop
dithering about whether you might have missed something someone
thinks might suit you better, okay, but .... Well, whatever.
By the way, I'm still mildly curious about why you decided, without
testing, that it would not be a good idea to follow the suggestions
you were given about avoiding all that tedious cut-and-paste. In
Message-ID: <[email protected]>
you wrote
Oh, I asked about that. One apparently can not pass a function
pointer parameter as in C. The ways that were posted involved lookup
every time AFIACS and I judged that it might swamp what I was
measuring (checking if a character were in a set). So, to my chagrin,
I had to go with cut-and-paste.
It's interesting to me that you were able to reach this conclusion
(that using Java's alternative to function pointers *does* affect
benchmarking results) without doing any experiments -- I think
you're probably right, but I did some experiments before coming to
the same conclusion. "Whatever" again.