View
32
Download
0
Embed Size (px)
DESCRIPTION
Pleasures and Pitfalls of Profiling. Primož Gabrijelčič. What? When? How?. What Is profiling?. A form of dynamic analysis that measures some aspect of the program execution, typically: Memory usage Resource usage Frequency and duration of function calls. When to profile?. - PowerPoint PPT Presentation
Pleasures and Pitfalls of ProfilingPrimo Gabrijeli
What? When? How?
What Is profiling?A form of dynamic analysis that measures some aspect of the program execution, typically:Memory usageResource usageFrequency and duration of function calls
When to profile?We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. -Donald Knuth
ToolsOptimization by guesswork bad!Hardcoded time measurement and loggingProfilers
ProfilersSampling (statistical)InstrumentingSource instrumentingCode instrumenting(Event based)(Hypervisor)
Tools
AQTimesmartbear.com/products/development-tools/performance-profiling/Delphi, C++ Builder, .NET (incl. Silverlight), Java Integration with RAD Studio and Visual Studio D2006 and newer32- and 64- bitComes with XE and XE2 (limited version)$ 599
AQTimePerformance profilerAllocation (memory) profilerCoverage profilerStatic analysis profilerLoad library tracer profilerMore
ProDelphiwww.prodelphi.deDelphi 5 XE232- and 64- bitVery precise profilingFree version (20 procedures)Separate Ansi and Unicode versionSeparate 32- and 64- bit version50 90
Sampling Profilerdelphitools.info/samplingprofilerDelphi 5 XE (officially), works with XE2Measures time spent in OS DLLsWorks at line levelReal-time monitorFree
DIY
Fixing performance problems
Fixing performance problemsBetter algorithm Less memory allocationsLess string manipulationsUsing different Windows controlsFaster code Code optimizationHandcrafted assembler; using MMX/SSEAssembler tricks will not make up for bad design, however, they can make good design go faster.
Profiler FAILDistributed algorithms (GUI, messaging) are hard to profileOptimizing the inner code of an infinite loop doesnt helpIf time is spent in kernel, reason may be hard to find
Hands-on!
Questions?
- The last one is of special interest to us.*Commonly attributed to C.A.R.Hoare (wrongly, according to Wikipedia)*ToolsDont profile by guesswork*Sampling profilers cant get the full picture (they dont measureeverything) but they dont change the execution speed and can measure OS DLLs (and other stuff outside of programmers control)*AQTimeIn XE, XE2 (except Starter) limited version standalone for any Delphi**Helmuth J.H. Adolph*Eric Grange*Custom code*How to fix?*Assembler problemsLots of workNew, hard to find bugsHigher probability of future incompatibilities*