Download presentation
Presentation is loading. Please wait.
Published byBathsheba Parks Modified over 8 years ago
1
Boris Jabes Program Manager Visual C++ Microsoft Corporation
2
4 Perspectives Developer Tester Architect Database Developer
3
Today we talk about analysis, probing, measuring, understanding! 2 Features of VSTS 2 Types of Machine 2 Types of Applications
4
The earlier, the better. Tools available for native and managed code For native code (C++) Compiler switch (/analyze) Analyzes source code during a build For managed code (C++/C#/VB/…) Integrated tool (FXCop) Analyzes binaries after build
5
Identify bad coding patterns, such as Using uninitialized memory Possible buffer overruns … Many more 139 specific checks for C++ code http://msdn2.microsoft.com/en-us/library/a5b9aa09(VS.90).aspx Incorporates years of security expertise Best practice: use in daily builds / check-in process
7
void FillString(TCHAR* buf, size_t cchBuf, size_t cchBuf, char ch) { char ch) { for (size_t i = 0; i < cchBuf; i++) { buf[i] = ch; } } void FillString(TCHAR* buf, size_t cchBuf, size_t cchBuf, char ch) { char ch) { for (size_t i = 0; i < cchBuf; i++) { buf[i] = ch; } } void FillString(__out_ecount(cchBuf) TCHAR* buf, size_t cchBuf, char ch) { size_t cchBuf, char ch) { for (size_t i = 0; i < cchBuf; i++) { buf[i] = ch; } } void FillString(__out_ecount(cchBuf) TCHAR* buf, size_t cchBuf, char ch) { size_t cchBuf, char ch) { for (size_t i = 0; i < cchBuf; i++) { buf[i] = ch; } } Ideally, code should Tell a computer what to do Tell a human what it does Ensure a human can’t misuse it
8
Show amount of options
9
FxCop provides data for managed projects Maintainability Index Cyclomatic Complexity Depth of Inheritance Class Coupling Lines of Code
10
Detect memory corruptions and critical security vulnerabilities early New tool: Application Verifier Runs while application is executing Monitors the use of Win32 APIs and system objects
11
Checks performed: Attempting to use invalid handles Memory corruptions or issues in the heap Out of memory under low resources Correct usage of critical sections is occurring Only checks functions called during test execution
12
Question 1: Are you a)A (Code) Monkey? b)A (Computer) Programmer? c)A (Computer) Scientist? d)A (Software) Engineer? e)None of the above Question 2: Do you measure your application? a)Yes, with my imagination b)Yes, with a profiler c)No
13
Two modes Sampling Binaries not touched Samples on clock cycles, page faults, system calls, or performance counters Instrumentation Binaries are modified after build Probes for every single function call made by the program Use sampling to narrow down the problem Use instrumentation for detailed analysis
15
Performance data in isolation is not useful We need Goals to hit (e.g. frame rate) Old values to compare with
16
Make sure your app is CPU-bound Need to sample a short run? Higher sampling rate If possible, warm up the app Use attach and detach in the UI Identify culprit using sampling then switch to instrumented for more details Don’t make any assumptions before you measure
17
Full suite of command line tools Only 4MB! Visualize from the command line XML, CSVs (function, caller/callee, calltree) Roll your own analysis tools Visualize on another machine Set up symbol path VSPerfReport.exe –PackSymbols foo.vsp Move to a machine with VS
18
Instrumentation vsinstr vsperfcmd /start:trace /output:. VSP Execute your application vsperfcmd /shutdown Sampling vsperfcmd /start:sample /output:.VSP vsperfcmd /launch: /args: Execute your application vsperfcmd /shutdown
19
Profiling enables better optimizations Profiling enables unique optimizations Partial inlining Switch expansion Hot/Cold code separation Virtual Call speculation
20
Me – http://blogs.msdn.com/borisjhttp://blogs.msdn.com/borisj VC++ - http://blogs.msdn.com/vcbloghttp://blogs.msdn.com/vcblog
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.