Priyanka Leo wrote:
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:"optimization" can mean different things:
execution time
memory usage
simplicity to read
and how you'd optimize for each differs.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Junilu Lacar wrote:A blog post inspired by this thread: https://jlacar.github.io/coding/premature-optimization-1.html
...
Optimization shouldn’t be done on the basis of intuition. Developers are your biggest bottleneck in software development. Save their time and you’ll save more. Seek first to reduce development time by simplifying and clarifying your code. That’s where you’ll get the most return on your time and effort.
fred rosenberger wrote:"optimization" can mean different things:
...
simplicity to read
and how you'd optimize for each differs.
Jesse Silverman wrote:Beautiful post, and quite short too!
The optimisation in Java9 improved the performance of += greatly, but for large loops like in this thread (if you correct the operator), the difference is still significant.Jesse Silverman wrote:. . . old assumptions about the relative performance of + versus StringBuilder no longer apply . . .
Junilu Lacar wrote:
Jesse Silverman wrote:Beautiful post, and quite short too!
Thanks! Glad you liked it.![]()
Yeah, I'm working on writing short and to-the-point. I need a lot more practice though.![]()
Campbell Ritchie wrote:
The optimisation in Java9 improved the performance of += greatly, but for large loops like in this thread (if you correct the operator), the difference is still significant.Jesse Silverman wrote:. . . old assumptions about the relative performance of + versus StringBuilder no longer apply . . .
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Multiple +s in the same statement have never caused a performance issue. It is only in loops that they are a problem.Tim Holloway wrote:. . . "+" in string declarations caused . . . constant folding.) . . .
fred rosenberger wrote:I would have written a shorter letter, but I did not have the time. - Blaise Pascal
Campbell Ritchie wrote:This link is too long, so I didn't have time to read it all. I don't know whether it comes to any decisions about whom to attribute that quote to.
Campbell Ritchie wrote:This link is too long, so I didn't have time to read it all. I don't know whether it comes to any decisions about whom to attribute that quote to.
RTFJD (the JavaDocs are your friends!) If you haven't read them in a long time, then RRTFJD (they might have changed!)
salvin francis wrote:
Is it just me or ... No one read the loop statement !!??!
Edit: Campbell spotted it first !
Priyanka Leo wrote:Guys i was asked the below question:
How to increase the performance of the following code:
Could you please help me with the solution for this ..
I still think the > is copied wrongly, in which case the answer should discuss +=, multiple +s in the same statement, StringBuilder, and the enhancements introduced in Java9.Damon McNeill wrote:. . . Assuming the code is copied verbatim . . .
Which an optimising JIT compiler might do at runtime anyway.. . . the loop can be deleted in any case.
That is a very tricky question !!Junilu Lacar wrote:...Oh, really. So what am I, cabbage soup? ;)
RTFJD (the JavaDocs are your friends!) If you haven't read them in a long time, then RRTFJD (they might have changed!)
You will be able to deliver high quality results in a rapidly changing environment that requires flexibility and adaptability with razor focus on speed to execute.
RTFJD (the JavaDocs are your friends!) If you haven't read them in a long time, then RRTFJD (they might have changed!)
depends on how interesting the conversation goes post that questionCampbell Ritchie wrote:Which approach will make you more likely to get the job, Salvin?
RTFJD (the JavaDocs are your friends!) If you haven't read them in a long time, then RRTFJD (they might have changed!)
That's a good point.Jesse Silverman wrote:. . . a skill we can pick up from comedians.)
Campbell Ritchie wrote:
I still think the > is copied wrongly, in which case the answer should discuss +=, multiple +s in the same statement, StringBuilder, and the enhancements introduced in Java9.Damon McNeill wrote:. . . Assuming the code is copied verbatim . . .
Which an optimising JIT compiler might do at runtime anyway.. . . the loop can be deleted in any case.
We don't know that the str variable won't be needed by later code, so we might want to retain its declaration.
Junilu Lacar wrote:Don't lose sight of the fact that this came up in an interview. The point is to find out what the candidate knows, not to show exemplars of how to write code.
Perseverance is best when informed.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |