0
Visual Studio Profiler
let’s start a profiling session !
Maxime Lemaitre – 23/07/2013
Profiling
Tools
• Let developers measure, evaluate, and target performance-related
issues in their code
– CPU, Memory, Concurrency, ADO.NE...
Here is the general process :
• Configure the performance session by specifying
the profiling method and the data that you...
There are 4 profiling available methods
• CPU Sampling
– Collects application statistics that are useful for
initial analy...
The sampling profiling method of the Profiling Tools interrupts the computer processor at
set intervals and collects the f...
The instrumentation profiling method of the Profiling Tools records detailed timing
information for the function calls, li...
The .NET memory allocation profiling method of Profiling Tools collects information
about the size and number of objects t...
Resource contention profiling collects detailed call stack information each time
competing threads in an application are f...
• Adds information to a profiling data file about synchronous ADO.NET calls
between an application and a SQL Server databa...
10
Profiling Quick Start
this often begins
with a wizard …
11
Profiling Wizard
Profiling Method Targets
TIP ?
Js ?
• Enables us to configure and start performance sessions
– Created/Filled by Performance Wizard
12
Performance Explorer
Se...
13
Profiling…
Pause
suspend data collection
Stop profiling
end the profiling session
When profiling you have nothing to do...
1 - Hot Path
branch of your application's call tree
that was most active when data was
collected
2 - Functions Doing the M...
There are also a few others Views
of profiling data files are displayed
• Call Tree
• Modules View
• Functions View
• Obje...
Demos
16
17
Demo #1
ASP.NET MVC 4 Sample (Magazine website)
Many Samples in Dal code and many calls to the db. Missing cache ?
18
Demo #2
Micro Benchmarking a Translation Helper (in Unit Test)
More than 93% of elapsed time is spent on Regex.Replace ...
19
Demo #3
Task cancellation Helper
For 100 000 tests, 300 000 tasks were allocated. Ouh !
For sure, memory consumption is...
• Profiling data can be collected through the ASP.NET profiler when we run a
web or a load test
– Limited to sampling and ...
• Instrumentation profiling can provide a greater level of detail ; this means
that more data is collected and instrumenta...
Right-click a test and choose Profile Test to
run performance analysis on a single unit test
22
Profiling Unit Tests
Since...
Questions ?
23
• http://msdn.microsoft.com/en-us/library/ms182372.aspx
• http://msdn.microsoft.com/en-us/library/z9z62c29.aspx
• http://b...
Find out more
• On https://techblog.betclicgroup.com/
About Betclic
• Betclic Everest Group, one of the world leaders in online gaming, has a unique
portfolio comprising variou...
Upcoming SlideShare
Loading in...5
×

Visual Studio Profiler

2,775

Published on

Quick overview on Visual Studio 2012 Profiler & Profiling tools : the importance of the profiling methods (sampling, instrumentation, memory, concurrency, … ), how to run a profiling session, how to profile unit test/load test, how to use API and a few samples

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,775
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
46
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Visual Studio Profiler"

  1. 1. Visual Studio Profiler let’s start a profiling session ! Maxime Lemaitre – 23/07/2013 Profiling Tools
  2. 2. • Let developers measure, evaluate, and target performance-related issues in their code – CPU, Memory, Concurrency, ADO.NET… • Command-line tools but fully integrated into the IDE • Since VS 2012, available in Pro Version • Really powerful tools but poorly documented/blogged • Needs knowledge on the application and on .net framework Introduction on MSDN 2 Profiling Tools Introduction
  3. 3. Here is the general process : • Configure the performance session by specifying the profiling method and the data that you want to collect. • Collect profiling data by running the application in the performance session. • Analyze the data to identify the performance issue. • Modify code with the goal to increases the application performance of the code • Collect profiling data on the changed code, and compare the profiling data of the original and changed data. • Generate a report that documents the increase in performance. 3 Profiling Workflow
  4. 4. There are 4 profiling available methods • CPU Sampling – Collects application statistics that are useful for initial analysis and for analyzing CPU utilization issues. • Instrumentation – Collects detailed timing data that are useful for focused analysis and for analyzing input/output performance issues. • .NET Memory Allocation – Collects .NET Framework memory allocation data by using the sampling profiling method. • Concurrency – Collects numeric resource contention data. 4 Choosing a Profiling Method Can be attached to a running process !
  5. 5. The sampling profiling method of the Profiling Tools interrupts the computer processor at set intervals and collects the function call stack. The profiler analysis determines whether the processor is executing code in the target process. If the processor is not executing code in the target process, the sample is discarded. • Inclusive samples – The total number of samples that are collected during the execution of the target function. – This includes samples that are collected during the direct execution of the function code and samples that are collected during the execution of child functions that are called by the target function. • Exclusive samples – The number of samples that are collected during the direct execution of the instructions of the target function. – Exclusive samples do not include samples that are collected during the execution of functions that are called by the target function. • Inclusive percent • Exclusive percent 5 Sampling Profiling Method Too Many Samples ? - Slow piece of code - Too many calls to a piece of code => For sure, there is something to optimize
  6. 6. The instrumentation profiling method of the Profiling Tools records detailed timing information for the function calls, lines, and instructions in the profiled application The instrumentation method injects code at the start and end of target functions in the profiled binary, and before and after each call by those functions to other functions. The injected code records interval between collects and OS operations. • Elapsed Inclusive values – The total time that was spent executing a function and its child functions. • Elapsed Exclusive values – The time that was spent executing a function, excluding time that was spent in child functions. • Application Inclusive values – The time that was spent executing a function and its child functions, excluding time that was spent in operating system events. • Application Exclusive values – The time that was spent executing a function, excluding the time that was spent in child functions and the time that was spent in operating system events. • Elapsed Inclusive & Exclusive percent • Application Inclusive & Exclusive percent 6 Instrumentation Profiling Method
  7. 7. The .NET memory allocation profiling method of Profiling Tools collects information about the size and number of objects that were created in an allocation or destroyed in a garbage collection and a few additional information. The memory profiler interrupts the computer processor at each allocation of a .NET Framework object in a profiled application. When object lifetime data is also collected, the profiler interrupts the processor after each .NET Framework garbage collection. The data is aggregated for each profiled function and for each type of object. • Allocation Data – Total counts and sizes of the allocated or destroyed memory objects • Lifetime Data – Displays the number and size of the objects and the generation when they are reclaimed 7 Memory Profiling Method
  8. 8. Resource contention profiling collects detailed call stack information each time competing threads in an application are forced to wait for access to a shared resource. Resource contention reports display the total number of contentions and the total time that was spent waiting for a resource for the modules, functions, source code lines, and instructions in which the waiting occured. • Inclusive values – Contentions that were caused by child functions that were called by the function are included in inclusive values. • Exclusive values – Contentions caused by child functions are not included. The exclusive time for the function also includes only the wait times that were caused by statements in the function body. 8 Concurrency profiling method
  9. 9. • Adds information to a profiling data file about synchronous ADO.NET calls between an application and a SQL Server database • Can be added to profiling data that is collected with the sampling, instrumentation, .NET memory, or concurrency methods 9 Tier Interaction Hidden profiling method For example, 1204 requests to the Casino Home Page
  10. 10. 10 Profiling Quick Start this often begins with a wizard …
  11. 11. 11 Profiling Wizard Profiling Method Targets TIP ? Js ?
  12. 12. • Enables us to configure and start performance sessions – Created/Filled by Performance Wizard 12 Performance Explorer Session Name The name of the session. Right-click the session name to edit the session properties Targets Binaries that are to be profiled in the session. Can be a binary, a VS project, or Web site. Each target have own Properties. Reports Files that are generated for the session. Right-click a report name to open, remove, or export a profiler data file. Can compare two profiler data files.
  13. 13. 13 Profiling… Pause suspend data collection Stop profiling end the profiling session When profiling you have nothing to do : - Let is run for standalone app (Console, Test, ..) - Navigate between pages/forms (Web Site or Desktop)
  14. 14. 1 - Hot Path branch of your application's call tree that was most active when data was collected 2 - Functions Doing the Most Individual Work. functions with the highest exclusive samples 3 - Summary Timeline timeline graph & CPU usage 4 - Error List uses a set of rules to suggest ways of improving the profiling run and to identify possible performance problems 14 Summary View Summary depends on Profiling method !
  15. 15. There are also a few others Views of profiling data files are displayed • Call Tree • Modules View • Functions View • Object Lifetime View • Thread Details View • Tier Interaction Views • … 15 Analysis Results
  16. 16. Demos 16
  17. 17. 17 Demo #1 ASP.NET MVC 4 Sample (Magazine website) Many Samples in Dal code and many calls to the db. Missing cache ?
  18. 18. 18 Demo #2 Micro Benchmarking a Translation Helper (in Unit Test) More than 93% of elapsed time is spent on Regex.Replace … For sure, there is something to improve in the helper.
  19. 19. 19 Demo #3 Task cancellation Helper For 100 000 tests, 300 000 tasks were allocated. Ouh ! For sure, memory consumption is not optimal when task is already completed.
  20. 20. • Profiling data can be collected through the ASP.NET profiler when we run a web or a load test – Limited to sampling and tier interaction data – Not appropriate for long runs (profiler file can become large …) • Really powerful if you have real scenarios & test cases 20 Profiling ASP.NET Web & Load Tests You just have to select ASP.NET profiler for your test settings
  21. 21. • Instrumentation profiling can provide a greater level of detail ; this means that more data is collected and instrumentation is more likely to impact the performance • The Visual Studio profiler provides an API for controlling data collection from within an application – allow us to limit the amount of data that is collected during a profiling session. Simply add a reference to ToolsMicrosoft.VisualStudio.Profiler.dll (VSDirToolsPerformance Tools) 21 Profiler APIs
  22. 22. Right-click a test and choose Profile Test to run performance analysis on a single unit test 22 Profiling Unit Tests Since VS 2012 update 2 The test runs as usual followed by the analysis (sampling method). When analysis completes, you’ll see the classic summary view
  23. 23. Questions ? 23
  24. 24. • http://msdn.microsoft.com/en-us/library/ms182372.aspx • http://msdn.microsoft.com/en-us/library/z9z62c29.aspx • http://blogs.msdn.com/b/dotnet/archive/2013/04/04/net-memory-allocation- profiling-with-visual-studio-2012.aspx • http://blogs.msdn.com/b/anilchandra/archive/2012/09/24/test.aspx • http://blogs.msdn.com/b/visualstudioalm/archive/tags/diagnostics/ • http://blogs.msdn.com/b/dotnet/archive/2013/04/04/net-memory-allocation- profiling-with-visual-studio-2012.aspx 24 Appendices & References
  25. 25. Find out more • On https://techblog.betclicgroup.com/
  26. 26. About Betclic • Betclic Everest Group, one of the world leaders in online gaming, has a unique portfolio comprising various complementary international brands: Betclic, Everest Gaming, bet-at-home.com, Expekt… • Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association). • Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×