There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
manolis tsamis wrote:
I know I can simply write if (n1 % n2 == 0) ...
But it's not fast enough.
Currently I use:
double div = (double) n1 / (double) n2;
If (div == (int) div){
...
}
This is faster than the mod operator I just want to know if someone has a faster way from this.
How do you define "fast enough"?
Don't answer let the compiler do optimizations...I just look forward to any micro optimizations or such.
manolis tsamis wrote:Don't answer let the compiler do optimizations... Blah blah blah.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
manolis tsamis wrote:Don't answer let the compiler do optimizations... Blah blah blah.
Why shouldn't we? Or are you only interested in the answers you want to hear?
Ulf Dittmer wrote:
How do you define "fast enough"?
+1 on that. Without knowing that it makes no sense to optimize.
Tim Driven Development | Test until the fear goes away
Ulf Dittmer wrote:But even in that case the question "How do you define fast enough?" has an answer (faster than anybody else), and without knowing it it doesn't make much sense to start IMO, because the approaches could be rather different depending on where the goal line is.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tom Cooke wrote:My point here is that software optimisations are not the whole picture a lot of the time.
Winston Gutkowski wrote:Which surely suggests that it doesn't pay to publish?
Ulf Dittmer wrote:I don't understand what you're trying to say (or imply) here.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Jayesh A Lalwani wrote:Restarting JVM doesn't make sense. That sounds like a justification to sweep memory leaks under the rug.... Theoretically, restarting the JVM should cause a bigger "pause" than GC
Winston Gutkowski wrote:then why tell them how "fast" or "good" you are?
Ulf Dittmer wrote:
Jayesh A Lalwani wrote:Restarting JVM doesn't make sense. That sounds like a justification to sweep memory leaks under the rug.... Theoretically, restarting the JVM should cause a bigger "pause" than GC
It does make sense, and no, it's not about memory leaks. Of course restarting the JVM takes longer than a GC, but during that time the load balancer takes care not to send request to that machine, so there is no downtime. Whereas during an expensive GC, a request might get slowed down, or not get serviced at all - that's what this aims to avoid.
Henry Wong wrote:1. I have seen cases where the GC has been optimized like crazy, to try to get as much GC done by the new generation collector versus the old generation collector.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Tim Driven Development | Test until the fear goes away
Tim Cooke wrote:
With my Moderator hat on I also feel obliged to mention that this thread is essentially a duplicate of the OP's other thread here.
Consider Paul's rocket mass heater. |