[Htmlparser-developer] Java Performance question
Brought to you by:
derrickoswald
|
From: Somik R. <so...@ya...> - 2003-01-18 08:33:19
|
Hi Folks,
I was tinkering around with instanceof and under the impression that =
it causes a performance hit, I tried replacing it with a polymorphic =
mechanism - by which HTMLNode has a method getType(), and so do the =
other basic nodes. A match is then attempted like so :
if (node.getType()=3D=3DHTMLTag.TYPE)
instead of
if (node instanceof HTMLTag)
I have taken care that getType does not do object creation - it is a =
static object. One would expect the former to be faster.
But in a performance test (InstanceofPerformanceTest in =
org.htmlparser.tests) - I find the opposite behaviour.
Here's a graph showing the response of instanceof in blue and =
getType()=3D=3DHTMLTag.TYPE in pink -
http://htmlparser.sourceforge.net/design/pics/performance.gif
Does anyone have explanations ?
Regards,
Somik |