window phone programing pain and how to deal with

18
Windows Phone programming: pain and how to deal with Nguyen Thai Son

Upload: zaloapp

Post on 11-Apr-2017

786 views

Category:

Technology


0 download

TRANSCRIPT

Windows Phone programming: pain

and how to deal withNguyen Thai Son

Agenda

1. Image Cache - Why? What we need? How to used?

2. LINQ - Tip and trick to improve performance

Image Cache - Why? What we need? How to used?

1.1 Image Cache mechanism in WP

• Image has been cache in memory and has been release by garbage collector

• Cache policy compliance with HTTP/1.1 Cache Control directive

‒ Support Etag, max-age, Expires, Last-Modified …

1.2 Why we need other Image Cache?

• Windows Phone OS just cache your image in one session

• Current HTTP/1.1 Cache Control directive config is not the best

• Need control memory consume and Image life cycle

1.3 What we need to Cache Image

Local Cache

• Organize by folder

• Used FIFO rule to roll cache

1.4 How to used

• Cache every thing you can‒ Better on Control memory

• Short cache Temporary Image – which something like this

HTTP/1.1 302 OK Location: /default Cache-Control: no-store, no-cache, must-revalidate Date: Fri, 05 Jul 2013 20:05:03 GMT Content-Length: 0

How to used (cont)

• Only take what you need

• Download Image from Network should be held as Stack and have limit Stack size

12

3

4

How to used (cont)

• Scheduled to clean up local cache to avoid waste on disk - event permanent Image

LINQ - Tip and trick to improve performance

2.1.Existing problems with LINQ

• Write time increased when used one instance of DataContext many time

50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 10000

50

100

150

200

250

Write time

One instance 50 item / instance 1 item / instance

Existing problems with LINQ (cont)

• Read time increased rapidly when amount of record is growing

100 record 20K record

Read time (one record) 15 ms 242 ms

2.2.How to improve

• Write batch of Query

Time (ms)

Write each query (1000 query) 17866

Write batch query(1000 query) 1835

How to improve (cont)• Used CompiledQuery with Query has been called

frequently‒ Translate Linq query to SQL query => Run the query =>

Retrieve the data

100 times 3000 times

Non Compiled Query 2427 ms 101039 ms

Compiled Query 739 ms 50702 ms

How to improve (cont)• Only take which Entity you need

17

20K Record

Count Full Entity 2803

Count One Entity 607