Quantcast
Channel: What are the effects of exceptions on performance in Java? - Stack Overflow
Browsing latest articles
Browse All 19 View Live

Answer by john16384 for What are the effects of exceptions on performance in...

Using the attached code, on JDK 15, I get completely different results for the @Mecki test case. This basically runs the code in 5 loops, with the first loop a bit shorter to give the VM some time to...

View Article



Answer by gavenkoa for What are the effects of exceptions on performance in...

Great post about exception performance is:https://shipilev.net/blog/2014/exceptional-performance/Instantiating vs reusing existing, with stack trace and without, etc:Benchmark Mode Samples Mean Mean...

View Article

Answer by Jacek Cz for What are the effects of exceptions on performance in...

My opinion about Exception speed versus checking data programmatically. Many classes had String to value converter (scanner / parser), respected and well-known libraries too ;)usually has formclass...

View Article

Answer by Doval for What are the effects of exceptions on performance in Java?

Aleksey Shipilëv did a very thorough analysis in which he benchmarks Java exceptions under various combinations of conditions:Newly created exceptions vs pre-created exceptionsStack trace enabled vs...

View Article

Answer by manikanta for What are the effects of exceptions on performance in...

I've extends the answers given by @Mecki and @incarnate, without stacktrace filling for Java.With Java 7+, we can use Throwable(String message, Throwable cause, boolean enableSuppression,boolean...

View Article


Answer by David Jeske for What are the effects of exceptions on performance...

Exception performance in Java and C# leaves much to be desired. As programmers this forces us to live by the rule "exceptions should be caused infrequently", simply for practical performance...

View Article

Answer by inder for What are the effects of exceptions on performance in Java?

I changed @Mecki 's answer above to have method1 return a boolean and a check in the calling method, as you cannot just replace an Exception with nothing. After two runs, method1 was still either the...

View Article

Answer by Hot Licks for What are the effects of exceptions on performance in...

FYI, I extended the experiment that Mecki did:method1 took 1733 ms, result was 2method2 took 1248 ms, result was 2method3 took 83997 ms, result was 2method4 took 1692 ms, result was 2method5 took 60946...

View Article


Answer by Fuwjax for What are the effects of exceptions on performance in Java?

My answer, unfortunately, is just too long to post here. So let me summarize here and refer you to http://www.fuwjax.com/how-slow-are-java-exceptions/ for the gritty details.The real question here is...

View Article


Answer by inflamer for What are the effects of exceptions on performance in...

Just compare let's say Integer.parseInt to the following method, which just returns a default value in the case of unparseable data instead of throwing an Exception: public static int...

View Article

Answer by BorisOkunskiy for What are the effects of exceptions on performance...

Don't know if these topics relate, but I once wanted to implement one trick relying on current thread's stack trace: I wanted to discover the name of the method, which triggered the instantiation...

View Article

Answer by Alan Moore for What are the effects of exceptions on performance in...

A while back I wrote a class to test the relative performance of converting strings to ints using two approaches: (1) call Integer.parseInt() and catch the exception, or (2) match the string with a...

View Article

Answer by Mecki for What are the effects of exceptions on performance in Java?

It depends how exceptions are implemented. The simplest way is using setjmp and longjmp. That means all registers of the CPU are written to the stack (which already takes some time) and possibly some...

View Article


Answer by James Schek for What are the effects of exceptions on performance...

I've done some performance testing with JVM 1.5 and using exceptions was at least 2x slower. On average: Execution time on a trivially small method more than tripled (3x) with exceptions. A trivially...

View Article

Answer by Tom Hawtin - tackline for What are the effects of exceptions on...

HotSpot is quite capable of removing exception code for system generated exceptions, so long as it is all inlined. However, explicitly created exception and those otherwise not removed spend a lot of...

View Article


Answer by Lars Westergren for What are the effects of exceptions on...

I think the first article refer to the act of traversing the call stack and creating a stack trace as being the expensive part, and while the second article doesn't say it, I think that is the most...

View Article

Answer by qualbeen for What are the effects of exceptions on performance in...

Why should exceptions be any slower than normal returns?As long as you don't print the stacktrace to the terminal, save it into a file or something similar, the catch-block doesn't do any more work...

View Article


Answer by user38051 for What are the effects of exceptions on performance in...

Even if throwing an exception isn't slow, it's still a bad idea to throw exceptions for normal program flow. Used this way it is analogous to a GOTO...I guess that doesn't really answer the question...

View Article

What are the effects of exceptions on performance in Java?

Question: Is exception handling in Java actually slow?Conventional wisdom, as well as a lot of Google results, says that exceptional logic shouldn't be used for normal program flow in Java. Two reasons...

View Article
Browsing latest articles
Browse All 19 View Live




Latest Images