Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Table of Contents
About the Author
About the Technical Editor
Acknowledgements
Introduction
Purpose of this Book
Why Should You Choose Managed Code?
Is Managed Code Slower Than Native Code?
Am I Giving Up Control?
Work With the CLR, Not Against It
Layers of Optimization
Sample Source Code
Why Gears?
Chapter 1 Performance Measurement and Tools
Choosing What to Measure
Average vs. Percentiles
Measurement Tools
Summary
Chapter 2 Garbage Collection
Basic Operation
Configuration Options
Reduce Allocation Rate
The Most Important Rule
Reduce Object Lifetime
Reduce Depth of Trees
Reduce References between Objects
Avoid Pinning
Avoid Finalizers
Avoid Large Object Allocations
Avoid Copying Buffers
Pool Long-Lived and Large Objects
Reduce Large Object Heap Fragmentation
Force Full GCs in Some Circumstances
Compact the Large Object Heap On-Demand
Get Notified of Collections Before They Happen
Use Weak References for Caching
Measuring and Investigating GC Performance
Summary
Chapter 3 JIT Compilation
Benefits of JIT Compilation
Costs of JIT Compilation
JIT Compiler Optimizations
Reducing JIT and Startup Time
Optimizing JITting with Profiling
When to Use NGEN
When JIT Can’t Compete
Measurement
Summary
Chapter 4 Asynchronous Programming
Use Tasks
Parallel Loops
Avoid Blocking
Use Tasks for Non-Blocking I/O
Async and Await
A Note on Program Structure
Use Timers Correctly
Ensure Good Startup Thread Pool Size
Do Not Abort Threads
Do Not Change Thread Priorities
Thread Synchronization and Locks
Measurement
Summary
Chapter 5 General Coding and Class Design
Class vs. Struct
Override Equals and GetHashCode for Structs
Virtual Methods and Sealed Classes
Interface Dispatch
Avoid Boxing
for vs. foreach
Casting
P/Invoke
Delegates
Exceptions
Dynamic
Code Generation
Preprocessing
Measurement
Summary
Chapter 6 Using the .NET Framework
Understand Every API you call
Multiple APIs for the Same Thing
Collections
Strings
Avoid APIs that Throw Exceptions under Normal Circumstances
Avoid APIs That Allocate From the Large Object Heap
Use Lazy Initialization
The Surprisingly High Cost of Enum
Tracking Time
Regular Expressions
LINQ
Reading Files
Optimize HTTP Settings and Network Communication
Reflection
Measurement
Summary
Chapter 7 Performance Counters
Consuming Existing Counters
Creating a Custom Counter
Summary
Chapter 8 ETW Events
Defining Events
Consume Custom Events in PerfView
Create a Custom ETW Event Listener
Get Detailed EventSource Data
Custom PerfView Analysis Extension
Summary
Chapter 9 Windows Phone
Tools
Garbage Collection and Memory
JIT
Asynchronous Programming and Memory Models
Other Considerations
Summary
Chapter 10 Code Safety
Understand the Underlying OS, APIs, and Hardware
Restrict API Usage in Certain Areas of Your Code
Centralize and Abstract Performance-Sensitive and Difficult Code
Isolate Unmanaged or Unsafe Code
Prefer Code Clarity to Performance Until Proven Otherwise
Summary
Chapter 11 Building a Performance-Minded Team
Understand the Areas of Critical Performance
Effective Testing
Performance Infrastructure and Automation
Believe Only Numbers
Effective Code Reviews
Education
Summary
Appendix A—Kick-Start Your Application’s Performance
Define Metrics
Analyze CPU Usage
Analyze Memory Usage
Analyze JIT
Analyze Asynchronous Performance
Appendix B—Big O Notation
Common Algorithms and Their Complexity
Appendix C—Bibliography
Useful Books
People and Blogs
Contact Information
← Prev
Back
Next →
← Prev
Back
Next →