Profiling and Optimization

From BlackBerryDev
Jump to: navigation, search

The content on this page is a compilation of various tips and tricks learned from DevCon presentations and personal experiences. It should be expanded upon and organized as appropriate.

Profiling and optimization

  • Optimization tricks that would be counterproductive in J2SE actually do help a lot on the BlackBerry JVM
  • Math, networking, persistence, file I/O, and compression have substantial and disproportionate performance differences between the simulator and the real device
    • Network I/O latency can be quite substantial, especially the lag when opening a fresh socket connection.
    • The biggest bottleneck with file I/O appears to be opening and closing files, not actually reading/writing data.
  • Consider compressing all persistent/file data, since reducing I/O helps performance a lot, and the zlib implementation in the API is actually pretty fast
  • 5.0+ can detect a process leak on the simulator
  • Look for "ApplicationRegistryHashtable" in the debugger when trying to trace an application reference
  • 4.5+ supports on-device profiling

Optimizing image data

  • JPEG
    • Remove metadata
    • Quality settings can sometimes go as low as 20-30% without the user noticing
  • PNG
    • Use less than 256 colors, PNG8 format
    • Use the "565" color-space if possible (this is the device color-space)
    • The BlackBerry theme development tools can export 565 and PNG8
  • Runtime memory cost of images:
    • Opaque: 2 x W x H / 1024 = KB
    • Semi-transparent: 3 x W x H / 1024 = KB
    • Use padding and margins instead of empty bitmap space, and crop icons closely

• Don't pre-composite images