Am 07.08.2013 17:39, schrieb Stefan Ram:
Sebastian<news@seyweiler.dyndns.org> writes:
Would you expect a measureable impact of creating these
variables ts1, ts2, instead of "inlining" the calls to
getEffectiveSequenceNumber(). (Using JDK 6?)
Creating objects on the heap is not so much effort, but
eventual garbage collection might take some time. However,
the compiler can perform an escape analysis and then
create the objects on the stack. A smart compiler could
even transform the code to the code written by Donkey.
Therefore, programmers nowadays often do not ask
?what is most efficient??, but ?what is most readable??.
I would agree. The reason I asked is we have a person in our group
who is very much in a micro-optimization mind-set. Among the things
that concern him are, for example, temporary local variables, wrappers
as method arguments wasting heap space compared to primitives,
multiple hash map lookups (containsKey() followed by get()) etc.
I sometimes find his code inelegant and unclear and would like to know
that it cannot really be more efficient. But of course, I cannot
rewrite and profile all his stuff in order to convince him.
for developers like him back then.
unreadable and saves little on overall execution time.
But you may find it difficult to convince him. Microoptimizers
believe very strongly in their religion.
you measure the real application before and after the change.
refer to his own micro-benchmark.