Pragmatic Performance: When to care about perf, and what to do about it.
summary
Practical rules: measure before changing and measure after, using BenchmarkDotNet to get repeatable results (it runs millions of iterations, warms up the JIT, and reports time and allocation). Examples: string join is 358ns vs an Aggregate at 918ns for small arrays; empty Dictionary is twice as fast and allocates less than using it via an IDictionary interface (boxing overhead); Span<T> beats Substring and .NET Core improves allocations.
AI-written summary · about
chapters (23)
- 0:00Introduction
- 1:30Premature optimization
- 4:25Donald Knuth
- 5:21Debugging and maintenance
- 6:47Coding is about tradeoffs
- 8:21Know the context
- 13:50Code Profiling
- 16:42Benchmarknet
- 18:03Demo
- 18:22Writing a benchmark
- 22:01Baseline
- 25:44Benchmarks
- 27:58Results
- 30:10Whats more important
- 32:02Dictionary benchmarks
- 32:47Coding standards
- 34:29Loops vs Link
- 35:49Link has other benefits
- 37:05Substring vs Span
- 38:16Span vs substring
- 39:34Swapping out components
- 40:20The perfect performance story
- 42:21Summary
related talks
54mPragmatic Performance: When to care about perf, and what to do about it
47mUnlocking Performance Improvements in .NET
56mState of the .NET Performance
37mRock Your Code Code and App Performance for Microsoft .Net
47mSolving .NET performance issues
59mWriting (in)efficient C#
59mPerformance tricks I learned from contributing to open source .NET packages
01h 04mTurbocharged: Writing High-Performance C# and .NET Code
