[Issue 9584] Exceptions in D are ludicrously slow (far worse than Java)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 25 10:34:32 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9584



--- Comment #5 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-02-25 10:34:29 PST ---
> But even so, I'm a bit suspicious of that Java code. Is it really throwing an
> exception? If it contains any exception handling optimisations at all, it
> would optimize the throw/catch away.

Hmm. A valid point. I hadn't thought of that. However, even just adding a line
to make it print the exception makes it take only about 250 - 350 microseconds
(which includes whatever cost there is to actually printing) on a machine
that's taking around 15 microseconds with the code in the bug, and if I make it
save the string from the exception before the end of the timing code but put
the print statement for the exception (now printing the saved string rather
than the exception) it's taking about 35 microseconds. Wrapping the throw in
another function doesn't seem to have much effect on performance either.

So, it may be that there's some optimizing going on with regards to the
exception in Java, but even with actually using it (which I would think would
force it to not be optimzed away), the D implementation is still taking orders
of magnitude longer than the Java implementation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list