booster votre application windows phone 8
DESCRIPTION
A l'heure des interfaces naturelles, vos utilisateurs attendent de votre application qu'elle soit particulièrement réactive. Sur la base de retours d'expériences, nous verrons comment votre application peut consommer moins de mémoire et solliciter moins le processeur, et répondre aux moindres sollicitations. De l'utilisation de l'analyseur de performances à l'implémentation de trucs et astuces, vous repartirez de cette session avec le plein d'idées pour améliorer les performances de votre applicationTRANSCRIPT
![Page 1: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/1.jpg)
Boostez votre application
Windows Phone 8Charlotte GAIDON, Jérémy ALLES
Pôle expertise Microsoft Grenoble
THALES
APP103
www.2day-app.com
Boostez votre application WP8
bit.ly/perfwp7
![Page 2: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/2.jpg)
Charlotte Gaidon
Formatrice WPF / Silverlight
@nutchad
Cœur de métier : applications industrielles
Agence de 200 collaborateurs à Grenoble
Pôle d’expertise sur les technologies Microsoft
Présentation
Jérémy Alles
MVP / WPF Disciples
@jalpf
www.japf.fr
Boostez votre application WP8 213/02/2013
![Page 3: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/3.jpg)
Agenda
• Quoi de neuf WP8 ?
• Sans les mains !
• Avec un peu de bonne volonté !
• Pour les plus courageux !
13/02/2013 Boostez votre application WP8 3
![Page 4: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/4.jpg)
CE QUI CHANGE AVEC WP8
Quoi de neuf docteur ?
13/02/2013 Boostez votre application WP8 4
![Page 5: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/5.jpg)
Flashback
13/02/2013 Boostez votre application WP8 5
![Page 6: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/6.jpg)
Nouveau noyau
• Windows Phone 7 : noyau CE de Windows
Mobile
• Windows Phone 8 : noyau NT Windows 8Recoupement entre les runtimes « Desktop » et « Phone »
SharedAPI
13/02/2013 Boostez votre application WP8 6
![Page 7: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/7.jpg)
Et mes applis ?
Compatibilité avec les 120 000 applis existantes !
WP8 Runtime
WP8 AppWP7.x App
Quirks Mode
Shim
Upgrade to WP8
bit.ly/perfwp8-upgrade
13/02/2013 Boostez votre application WP8 7
![Page 8: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/8.jpg)
• dual-core 1024 Mo de RAM– devices puissants
– encore d’intérêt à paralléliser
• résolutions plus grandes
• 2 formats possibles
Nouveau hardware
Application.Current.Host.Content.ScaleFactor
13/02/2013 Boostez votre application WP8 8
![Page 9: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/9.jpg)
NOUVEAUX OUTILS
13/02/2013 Boostez votre application WP8 9
![Page 10: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/10.jpg)
Nouvel émulateur
• Différentes caractéristiques de device
• Hyper-V (processeur SLAT requis)
• Attention aux perfs dans l’émulateur WP7
13/02/2013 Boostez votre application WP8 10
![Page 11: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/11.jpg)
Profiling et Monitoring
VS2012 apporte des nouveautés
13/02/2013 Boostez votre application WP8 11
![Page 12: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/12.jpg)
13/02/2013 Boostez votre application WP8 12
![Page 13: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/13.jpg)
Rappel des bonnes pratiques
• Limiter la taille de l’arbre visuel
• Fuites mémoire : attention aux events !
• Tirer parti du thread compositor– ScaleTransform vs animation FontSize
– TranslateTransform vs animation Margin
13/02/2013 Boostez votre application WP8 13
bit.ly/perfwp7
![Page 14: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/14.jpg)
Economie d’énergie
• Utiliser la compression GZip
• Regrouper les requêtes web
• Thème foncé vs thème clair
• JPEG plus économe que PNG
13/02/2013 Boostez votre application WP8 14
bit.ly/perfwp8-gzip
![Page 15: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/15.jpg)
Simulation Dashboard
• Connexion réseau
• Ecran de verrouillage
• Rappel
13/02/2013 Boostez votre application WP8 15
![Page 16: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/16.jpg)
C# Async bit.ly/perfwp8-async
13/02/2013 Boostez votre application WP8 16
![Page 17: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/17.jpg)
Boostez votre application WP8 – Sans les mains !
SANS LES MAINS !
Sit down and relax
13/02/2013 Boostez votre application WP8 17
![Page 18: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/18.jpg)
• Fill Rate– WP7 : limite entre 2 et 4
– WP8 : limite entre 5 et 6
Surface counter
UI thread frame rate
Texture memory usage
Composition thread frame
rate
Screen fill rate counter
Intermediate surface counter
13/02/2013 Boostez votre application WP8 18
Les compteurs
Current.Host.Settings.EnableFrameRateCounter
Current.Host.Settings.EnableRedrawRegions
![Page 19: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/19.jpg)
Gains en performances
• Progress Bar
• Panorama
• LongListSelector
• ViewPortControl– Off thread input
13/02/2013 Boostez votre application WP8 19
![Page 20: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/20.jpg)
COMPILATION DANS LE
Accrochez-vous
13/02/2013 Boostez votre application WP8 20
![Page 21: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/21.jpg)
Du code C# au code machine
Code machine
Compilateur
C#
Compilateur
JIT
Dev
ice
Intermediate
LanguageCode C#
Dév
elo
pp
eur
13/02/2013 Boostez votre application WP8 21
![Page 22: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/22.jpg)
Génération et utilisation du code machine
• Avantages– Le code IL est indépendant de la machine
– On ne compile pas le code dont on ne se sert pas
• Inconvénients– Ajoute un surcoût à l’exécution
– Handicap pour le temps de démarrage des applications
13/02/2013 Boostez votre application WP8 22
![Page 23: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/23.jpg)
Une solution ?
• Ne plus faire de code IL ?
• Faire le JIT « à l’avance » ?
• Ce n’est pas une idée nouvelle : NGEN– Exemple : Paint.Net
13/02/2013 Boostez votre application WP8 23
![Page 24: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/24.jpg)
NGEN
Code machine
Compilateur
C#NGEN
Intermediate
LanguageCode C#
13/02/2013 Boostez votre application WP8 24
![Page 25: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/25.jpg)
NGEN : oui, mais…
Mscorlib.dll
App1.exeLibrary.dll
App2.exe
13/02/2013 Boostez votre application WP8 25
![Page 26: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/26.jpg)
NGEN : oui, mais…
Mscorlib.dll
App1.exeLibrary.dll
App2.exe
13/02/2013 Boostez votre application WP8 26
![Page 27: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/27.jpg)
NGEN : oui, mais…
Mscorlib.dll
App1.exeLibrary.dll
App2.exe
13/02/2013 Boostez votre application WP8 27
![Page 28: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/28.jpg)
De quoi a-t-on besoin ?
• Un démarrage rapide– Supprimer le coût du JIT au démarrage
• Déploiement facile et rapide– Temps d’exécution de NGEN trop long
• Pouvoir gérer les mises à jour de l’OS– Ne pas perdre les images compilées après update
13/02/2013 Boostez votre application WP8 28
![Page 29: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/29.jpg)
Recompilation en cascade : pourquoi ?class Base
int
string
virtual void
class AppDerived
int
int int return
0x0 MethodTable
0x4 i
0x8 s
0xC j
0x0 MethodTable
0x4 i
0x8 s
13/02/2013 Boostez votre application WP8 29
![Page 30: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/30.jpg)
int foo(int a) { return a + j; }
13/02/2013 Boostez votre application WP8 30
0x0 MethodTable
0x4 i
0x8 s
0xC j
![Page 31: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/31.jpg)
Evolution de la classe mère
class Base
int
string
int
virtual void
0x0 MethodTable
0x4 i
0x8 s
0xC k
13/02/2013 Boostez votre application WP8 31
![Page 32: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/32.jpg)
L’offset devrait
être 0x10 !
Le code généré devient invalide
0x0 MethodTable
0x4 i
0x8 s
0xC k
0x10 j
13/02/2013 Boostez votre application WP8 32
![Page 33: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/33.jpg)
Remplacé via une
étape de link
supplémentaire
Idée : marquer les potentiels
changements…
13/02/2013 Boostez votre application WP8 33
![Page 34: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/34.jpg)
Résumé : MDIL
• Compiler ce qui ne changera jamais directement
• Ajouter des tokens pour ce qui pourra changer
• Remplacer les tokens au moment de l’install
• Mise à jour refaire l’édition de lien à nouveau
13/02/2013 Boostez votre application WP8 34
![Page 35: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/35.jpg)
Pourquoi compilation « dans le nuage » ?
C# CompilerC# Source
Code
MSIL
AssemblyMDIL
Compiler
MDIL
Assembly
MDIL
Assembly
Téléchargement sur
le device
Native
Image
Generator
Native
DLL Exécution
Cette partie se
passe “dans le
cloud” !
13/02/2013 Boostez votre application WP8 35
![Page 36: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/36.jpg)
De quoi avait-on besoin ?
• Un démarrage rapide
• Déploiement facile et rapide
• Pouvoir gérer les mises à jour de l’OS
13/02/2013 Boostez votre application WP8 36
![Page 37: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/37.jpg)
Comment tester ?
• Avoir un vrai device
13/02/2013 Boostez votre application WP8 37
![Page 38: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/38.jpg)
AVEC UN PEU DE BONNE VOLONTÉ
!
13/02/2013 Boostez votre application WP8 38
![Page 39: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/39.jpg)
La consommation mémoire
• Respecter la limite– Mesurer la consommation mémoire
• 2 nouveaux paramètres de BitmapImage– DecodePixelWidth
– DecodePixelHeight
bit.ly/perfwp8-memory
13/02/2013 Boostez votre application WP8 39
![Page 40: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/40.jpg)
SLIDE SHOW
Compteur mémoire
démo
13/02/2013 Boostez votre application WP8 40
![Page 41: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/41.jpg)
DÉMARRAGE ÉCLAIR
Fast-App-Resume
13/02/2013 Boostez votre application WP8 41
![Page 42: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/42.jpg)
WP7 VS W8
Multi-tasking
démo
13/02/2013 Boostez votre application WP8 42
![Page 43: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/43.jpg)
Fast-App-Switching ou Fast-App-Resume
?
Création d’une nouvelle instance
Reprise de l’instance suspendue
Switch
Resume
13/02/2013 Boostez votre application WP8 43
![Page 44: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/44.jpg)
WP7 VS WP8
Fast-App-Resume
démo
13/02/2013 Boostez votre application WP8 44
![Page 45: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/45.jpg)
2 stratégies pour le Fast Resume
Que se passe-t-il si on presse le bouton « back » juste après un fast resume ?
1. Afficher la dernière page visitée : « resume experience »annuler la navigation : e.Cancel = true;
2. Quitter l’application : « fresh instance experience »vider la back stack : RootFrame.RemoveBackEntry()
13/02/2013 Boostez votre application WP8 45
![Page 46: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/46.jpg)
Limitation du Fast Resume
• Pas disponible pour applis Direct3D
• Pas disponible pour WP7.8
• Mise à jour d’une tuile à la sortie de l’appli– Deactivated
– OnNavigationFrom
• Speech recognition
13/02/2013 Boostez votre application WP8 46
![Page 47: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/47.jpg)
POUR LES PLUS COURAGEUX
13/02/2013 Boostez votre application WP8 47
![Page 48: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/48.jpg)
UTILISER DU CODE NATIF
“C makes it easy to shoot yourself in the foot; C++ makes it harder,
but when you do it blows your whole leg off” (Bjarne Stroustrup)
13/02/2013 Boostez votre application WP8 48
![Page 49: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/49.jpg)
Cas d’utilisation C++
1
2
3
Performance
Réutilisation
Portabilité
13/02/2013 Boostez votre application WP8 49
![Page 50: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/50.jpg)
Le SDK 8.0 ouvre la voie au code natif
Différents scénarios
– 100% natif : application Direct3D
– Hybride natif/managé
• Implémentation d’un traitement en C/C++
• Réutilisation d’une librairie existante
13/02/2013 Boostez votre application WP8 50
![Page 51: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/51.jpg)
RValue references Forward declared enums Bidirectional fences
static_assert Alignment Data-dependency ordering
Auto Standard-layout and trivial types exception_ptr
Trailing return types Extended friend declarations Thread-local storage
Lambdas Local and unnamed types as template arguments __func__
Decltype Range-based for-loop C99 preprocessor
Right angle brackets override and final long long
extern templates Minimal GC support
nullptr Atomics
Strongly typed enums Strong compare and exchange
Support du C++ dans Windows Phone 8
• Visual C++ 2012
• Idem qu’avec Windows 8
• Nouvelles fonctionnalités C++11
13/02/2013 Boostez votre application WP8 51
![Page 52: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/52.jpg)
FILTRE DE CONTRASTE
C# vs C++
démo
13/02/2013 Boostez votre application WP8 52
![Page 53: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/53.jpg)
UN CUBE QUI TOURNE !
Interop XAML / D3D
démo
13/02/2013 Boostez votre application WP8 53
![Page 54: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/54.jpg)
CONCLUSION
Réveillez-vous !
13/02/2013 Boostez votre application WP8 54
![Page 55: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/55.jpg)
Conclusion
• Sans les mains– Compilation dans le cloud
• Avec un peu de bonne volonté– Fast-App-Resume
• Pour les plus courageux– Interop C++/DirectX/XAML
• Et un SDK 8.0 très riche en nouveautés
13/02/2013 Boostez votre application WP8 55
![Page 56: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/56.jpg)
Accélérateur Windows
Ressources
Coaching
Visibilité
aka.ms/accelerateur-windows
Plus d’info ? RDV stand Windows 8
L’Accélérateur Windows
![Page 57: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/57.jpg)
Merci !
Charlotte Gaidon
Formatrice WPF / Silverlight
@nutchad
Merci à Alex & Pierre (Microsoft) et aux collègues ;-)
Retrouvez-nous sur le stand 58
Jérémy Alles
MVP / WPF Disciples
@jalpf
www.japf.fr
2day-app.com
13/02/2013 Boostez votre application WP8 57
![Page 58: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/58.jpg)
Donnez votre avis !
Depuis votre smartphone, sur :
http://notes.mstechdays.fr
De nombreux lots à gagner toutes les heures !!!
Claviers, souris et jeux Microsoft…
Merci de nous aider à améliorer les TechDays
http://notes.mstechdays.fr
![Page 59: Booster votre application Windows Phone 8](https://reader034.vdocument.in/reader034/viewer/2022042817/559cfce51a28aba97f8b458f/html5/thumbnails/59.jpg)
Formez-vous en ligne
Retrouvez nos évènements
Faites-vous accompagner
gratuitement
Essayer gratuitement nos
solutions IT
Retrouver nos experts
Microsoft
Pros de l’ITDéveloppeurs
www.microsoftvirtualacademy.comhttp://aka.ms/generation-app
http://aka.ms/evenements-
developpeurshttp://aka.ms/itcamps-france
Les accélérateurs
Windows Azure, Windows Phone,
Windows 8
http://aka.ms/telechargements
La Dev’Team sur MSDN
http://aka.ms/devteam
L’IT Team sur TechNet
http://aka.ms/itteam