I think Alan Moore wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Ernest,
> 

> From my experience debugging some jess code, I noticed that a
> NumberFormatException is thrown on a somwhat regular basis during
> parsing. I assume that some part of the parser is checking to see if
> a symbol is a number or not in order to determine RU.XXX types.

Yus -- unfortunately, no other way to use Java's built-in number
parsers. 

> Do you know how much, or if at all, this exception slows down
> parsing? From what I have read about exceptions is that they can
> significantly slow execution of a program but this may be old news
> (hotspot?) or just a bad rumor.

Well, exceptions are "expensive" in the sense that they involve
creating the Exception object itself, so you don't want to use them in
a critical inner loop. There's also a table lookup involved in
catching them, but that's comparable to the "tableswitch" opcode used
to implement Java's "switch" keyword.

In a parser, where little strings are being created and cut up and
discarded left and right, a few NumberFormatException objects don't
have much of an impact.

I've always assumed that Java's built-in Integer.parseInt() and
Double.parseDouble() were faster than anything I could code by
hand. Maybe this is a bogus assumption, but if it's true, then to
eliminate the NumberFormatExceptions you'd have to  accept the
overhead of a new, slower, number parser.


> Given that it is only thrown during parsing it shouldn't amount to
> much percentage-wise of a typical jess program so I am not really
> concerned - just curious. Have you done any profiling in this area?
> Comments?

Not a whole lot of energy goes into speeding up the parser, as in
general, as you'd expect, parsing time is a fairly smalll percentage
of the application runtime. In fact, when I do profile Jess
(gratuitous plug for OptimizeIt, a great tool!), parsing stuff doesn't
even show up -- it's all down at the bottom of the list.


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to