Tải bản đầy đủ (.pdf) (33 trang)

Session 07 kho tài liệu bách khoa

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.55 MB, 33 trang )

Advanced Windows Store Apps Development – II


 Define Profiling
 Create a Performance Report
 Explain Diagnostic Tools for Store apps in Visual Studio 2013

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

2


Each Store app developed by the user is a client app that performs in a sandboxed
and responsive atmosphere. In some cases, the user can identify some of the apps
that perform slowly. The main reasons for the app to deliver poor performance are
as follows:

An ineffective code that slows down the App

Referring to any third-party libraries

Remote services that takes more time to load

Writing complex calculations that takes away too much of CPU’s time and capacity

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7


3


Profiling and Collecting Performance Counters
There are two main profiling techniques:

© Aptech Ltd.

Sampling

Instrumentation

Sampling is the only option
available in Windows Store app,
with some limitations (some
sampling options, such as setting
the sampling event and timing
interval, or collecting additional
performance counter data does
not supported for Windows Store
apps).

Instrumentation profiler, on the
other hand, follows a more
invasive approach because it
injects specific tracing code at the
beginning and end of the each
function. This tracing code enables
the profiling tool to record each
time the execution flow enters

and exits an instrumented
function.

Diagnosing Problems and Monitoring Applications/Session 7

4


Concurrency Profiling
This profiling method collects detailed information from the call stack each time while the
competing threads forced to wait for access to a shared resource. It also provides useful
information about how an application interacts with the overall environment, enabling the
user to identify performance bottlenecks, synchronization issues, and so on.
.NET memory profiling:
This profiling method collects detailed information about memory
allocation and garbage collection.

Tier Interaction Profiling (TIP):
This
This profiling
profiling method
method collects
collects information
information about
about ADO.NET
ADO.NET function
function that
that
calls to a SQL Server database.


© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

5


Tracing and Logging Events
 For logging, System.Diagnostics.Tracing namespace delivers types and members,
which allow the user to create strongly typed events. However, Windows Runtime supports
only a subset of the available types.
 The information that specifies for each event is as follows:
EventId - identifier for the event
Keywords - Keywords related to an event
Level - Represents the level of the event
LogAlways - Used by the listener
Critical - Represents a critical error
Error - Represents a standard error
Warning - Represents a warning event
Informational - Provide additional information on events
Verbose - Adds lengthy events or messages
Message - Message for the event
Opcode - Represents the operation code for the event
Task - Represents the task for the event
TypeId - Represents unique identifier for this attribute
Version - Represents the version of the event
© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7


6


As a developer of Store apps, the user must be aware of the errors and failures such as app
hanging, crashing, service unavailability, and many more conditions. Therefore, the best way
is to develop an app with minimum errors and bugs, so that finally the end users do not have
to suffer and shift to other similar competing apps. Windows Store apps has many ways to
monitor such pitfalls. These are as follows:
Using Windows Store Reports to Improve the Quality of App
Windows Store provides reporting for the app. Even a perfect app can crash any time. Each
exception is tracked inside the store and they are saved in the app summary as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

7


The following figure shows the Downloaded Exceptions Report.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

8


To view the error logs, the user has to install WinDbg software and using this software, the
developer can debug the errors. Once the software is installed, open the WinDbg.exe and

navigate to File  Open Crash Dump as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

9


Now, the user has to select the downloaded cab file from the app store. The figure shows the
Open Crash Dump window.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

10


Once the cab file is loaded, the user has to search c:\symbols and click OK button as shown in
figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

11


The user can then, view the reason for the error and it can be rectified or fixed in real time mode.

Such rectified errors will not reflect the next time the dump file is opened by using
WinDbg.exe. The figure shows the Error description as shown by the WinDbg.exe utility.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

12


Profiling Performance
The user can test the app performance at runtime. If the performance of the app is good, then,
it is ready for sale in the market. Users like only those apps that deliver better performance and
speed.
To test the performance, the user has to navigate to Debug  Performance and Diagnosis.
Then, the Performance wizard will open as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

13


The following figure shows the Sample Profiling Report.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7


14


Profiling Memory Usage
While developing the app, the user can check the memory load. Memory will increase in size
whenever more resource files are used. Resource includes images, style sheets, scripts, third
party DLLs, and many more. The developer can track the memory usage when the app is
running.
Right-click the Taskbar and select Task Manager from the Context Menu as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

15


When the Task Manager is opened, the user can view the memory usage of the app as shown
in figure. Depending upon the size, the app will be faster, and reliable. It shows the Task
Manager window that shows the details of memory allocated for the app as shown in the
following figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

16


Performance and Diagnostics

In order to use the performance and diagnostic tools, perform the following steps:
Step 1: Open the project on which the Performance Test is to be performed. Select Open Project
from the start page. Figure shows the Start page to open a New Project.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

17


Step 2: Select the project to check for the performance testing as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

18


Step 3: Navigate to Debug menu and select Performance and Diagnostics as shown in
following figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

19



Step 4: The user can view the window as shown in figure. The user can select any of the available
tools for testing. Three options are given by Visual Studio. These are CPU Sampling, Energy
Consumption, XAML UI Responsiveness, HTML UI Responsiveness, JavaScript Function Timing,
JavaScript Timing, and Performance.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

20


Step 5: This example will show how to process CPU Sampling. To test the CPU sampling, the user
has to select CPU Sampling from the Available Tools as shown in figure. Click the Start button to
start the testing.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

21


Step 6: Once the testing is started, the user can view the progress of the test as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

22



Step 7: As soon as the test is started, the DLLs will be loaded as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

23


Step 8: Before the completion of the test, the user can view the process as shown in figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

24


Step 9: After completion of the selected test, the result or the report is displayed as shown in
figure.

© Aptech Ltd.

Diagnosing Problems and Monitoring Applications/Session 7

25



×