April 24, 2008 at 12:45 am (HtmlUnit, Java, Optimization)
I just cut HtmlUnit’s build time by about 20% by changing four lines of code. How? HtmlUnit keeps a small cache of web requests in a HashMap, keyed on the request URL. The problem with this is twofold:
- The URL.hashCode() method is synchronized.
- The URL.hashCode() method triggers DNS lookups for the URL hosts.
The impact of item 2 was magnified by the fact that some of the HtmlUnit unit tests use a mock web connection to connect to fake URLs. DNS (non)resolution of these fake URLs took an especially long time.
The fix was to key the map entries on the value of URL.toString() instead. Apparently I’m not the first person to stumble across this problem. So think twice before coding your next HashMap<URL, XXX>
April 15, 2008 at 11:52 am (HtmlUnit, Java)
The HtmlUnit team is pleased to announce a new release of HtmlUnit. This latest version includes a number of bug fixes and performance enhancements, and sports excellent support for GWT, jQuery and Sarissa, decent support for Prototype and Dojo, and basic support for YUI. Please see the changelog for more details.
Anyway, give it a whirl and let us know what you think!
April 13, 2008 at 3:33 pm (Architecture, Quotes, Software)
I draw my idea of the form of government software from a principle in nature which no art can overturn, viz. that the more simple any thing is, the less liable it is to be disordered, and the easier repaired when disordered;…
– Thomas Paine, Common Sense (1776)