wp7 performance challenges

28
Real- World Performance for Windows Phone 7 WP7 Performance Challenges Gergely Orosz @GergelyOrosz

Upload: gergely-orosz

Post on 22-Jun-2015

888 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Wp7 performance challenges

Real- WorldPerformance

for WindowsPhone 7

WP7 Performance Challenges

Gergely Orosz@GergelyOrosz

Page 2: Wp7 performance challenges

WP7 Performance Challenges

• My Experience

• Everyday performance challenges

• Visually rich app performance challenges

• Computing intense performance challenges

Page 3: Wp7 performance challenges

My Experience

Page 4: Wp7 performance challenges

Cocktail Flow

Page 5: Wp7 performance challenges

Cocktail Flow Challenges

• Serialization / Deserilaization

• Animations

• Downloading packages: networking

• Rich ListBoxes

• Emulator vs physical device

Page 6: Wp7 performance challenges

Visiblox Charts for WP7

Page 7: Wp7 performance challenges

Visiblox Charts for WP7 Challenges

• Avoiding overloading of the UI thread

• Realtime drawing on the screen– How fast can you draw on the phone?

• Memory Leaks

• Data binding

• DPs

Page 8: Wp7 performance challenges

Real- WorldPerformance

for WindowsPhone 7

Everyday Performance Challenges

Page 9: Wp7 performance challenges

Networking & the UI

• Question

Page 10: Wp7 performance challenges

Networking & the UI

• WebClient: simple, easy

• … runs on the UI thread!• HttpWebRequest: complicated &performant

Page 11: Wp7 performance challenges

Serialization & Deserialization

• XmlSerializer

Page 12: Wp7 performance challenges

Serialization & Deserialization

• Binary Serialization• DataContractSerializer• Json.NET• sharpSerializer• Mike Talbot’s Silverlight Serializer• Sterling Isolated Storage DB• Ninja Database Pro

Page 13: Wp7 performance challenges

Serialization & Deserialization

Load Save

Page 14: Wp7 performance challenges

ListBox

• Cool in the beginning

• Rusty when you start adding stuff

• Awfully slow when you start tweaking visuals

• Pain to make it half as fast as on the iPhone

Page 15: Wp7 performance challenges

ListBox

• Slow with > 50-200 elements• Virtualized, but….• Several workarounds– Windows Phone Team: ListBox best practices– 3rd party Listbox (Telerik)– Implement paging

Page 16: Wp7 performance challenges

Emulator vs Physical Device

• Emulator usually 2-5x times faster• GPU intensive tasks: emulator can be slower

• Test (frequently) on the device

Page 17: Wp7 performance challenges

Small Things

• ProgressBar

• Splashscreen while loading

PerformanceProgressBar

Page 18: Wp7 performance challenges

Real- WorldPerformance

for WindowsPhone 7

Visually Rich App Performance Challenges

Page 19: Wp7 performance challenges

Frame Rate Counters

• FPS (render > 30, UI > 15)• Texture mem. usage• Fill Rate (<2.5)• Blog post explaining these

Page 20: Wp7 performance challenges

BitmapCache vs No Caching

• No caching GUP calculates every time• BitmapCache “screenshot” saved, no GPU

needed

Page 21: Wp7 performance challenges

BitmapCache vs no Caching

Page 22: Wp7 performance challenges

Image Do’s and Don’t‘s

• Fast (with BitmapCache):– Transforms: Scale, Rotate, Translate– Opacitiy change– Clipping region change

• Slow– Changing image with / height– OpacityMask– Non-rectangular clipping areas

• Jpegs are (somewhat) faster than pngs

Page 23: Wp7 performance challenges

Computing Intensive Applications

Page 24: Wp7 performance challenges

Avoid Overloading the UI Thread

• Use BackgroundWorker

• Throttle calls to UI while it’s busyvia the “render loop”:

– E.g a chart is redrawn whenever the Zoom changes– A chart redraw takes 100ms– The Zoom is changed at 0ms, 40ms, 80ms, 120ms– The chart will still be drawing at 40ms & 80ms!

Page 25: Wp7 performance challenges

Rendering Real-Time

• Lightweight vs heavyweight elements– Shapes vs Controls vs UserControls

• Drawing is more expensive than redrawing– Reuse existing elements

• WriteableBitmap & WriteableBitmapEx

• Working with large Paths: buggy, slow

Page 26: Wp7 performance challenges

Extreme Optimalizations

• Data Binding– Avoid when there are thousands of objects– Takes up memory & notifications may fire too

often• DPs– Only use if needed– Slow to read cache in CLR properties

Page 27: Wp7 performance challenges

Summary

• Networking & effect on UI thread

• Serialization & deserialization

• ListBox

• BitmapCaching

Page 28: Wp7 performance challenges

Closing Thoughts

• Use the performance counters

• Performance can be optimized– (or you can always cut features…)

• Test, test, test - on a device!

• MIX 2011 – performance tool?