Dalvik. A small village in iceland

July 21, 2010 Leave a comment

… that mostly lives from catching fish and leads a rural life, not doing that fancy stuff that those guys in the cities do.

How very fitting a name for the Android Java VM.

Yesterday I spent over an hour again re-engineering one of my Web Raid classes, the one that picks a fitting color name for a certain color. This class relies on a big list of names + colors taken from Wikipedia, and needs to find the closest match for a given RGB color. I was using a hash map that maps Hue values to lists of colors of that hue value and that then picks the best one.

This is blindingly fast with Hotspot.

With Dalvik, the little step of generating Integer objects for the int hue values slows down the VM to a crawl. Probably Dalvik uses the kind of ancient Garbage collector that Sun was using with 1.1…

Oh well. Now, with a simple array of 4*360 values (so I can have four different colors for one hue key) it works blindingly fast again. But I notice that I need to rewrite major portions of Web Raid to run on an Android device.

Categories: dalvik