@@ -166,6 +166,104 @@ Outputs are written to `profile-output/` in the current working directory.
166166- ` --input <path> ` render existing ` nettrace ` , ` speedscope.json ` , ` etlx ` , or ` gcdump ` files
167167- ` --tfm <tfm> ` target framework when profiling a ` .csproj ` or ` .sln `
168168
169+ ## Profiler flags
170+
171+ ### --cpu
172+ Sampled CPU profiling with a call tree and top‑function table.
173+ Use this to find the hottest methods by time.
174+
175+ Example (examples/cpu):
176+ ``` bash
177+ dotnet build -c Release examples/cpu/CpuDemo.csproj
178+ asynkron-profiler --cpu -- ./examples/cpu/bin/Release/net10.0/CpuDemo
179+ ```
180+
181+ Sample output (top of call tree):
182+ ```
183+ Call Tree (Total Time)
184+ 327.41 ms 100.0% 1x Total
185+ └─ 299.66 ms 91.5% 1x Program.Main
186+ └─ 298.22 ms 91.1% 1x Program.RunWork
187+ └─ 281.02 ms 85.8% 1x Program.CpuWork
188+ └─ 276.10 ms 84.3% 3x Program.Fib
189+ ```
190+
191+ ### --memory
192+ Allocation profiling using GC allocation tick events, plus a per‑type call tree.
193+ Use this to find the biggest allocation sources.
194+
195+ Example (examples/memory):
196+ ``` bash
197+ dotnet build -c Release examples/memory/MemoryDemo.csproj
198+ asynkron-profiler --memory -- ./examples/memory/bin/Release/net10.0/MemoryDemo
199+ ```
200+
201+ Sample output (top of call tree):
202+ ```
203+ Allocation Call Tree (Sampled)
204+ Byte[] (20.06 MB, 69.4%, 198x)
205+ 20.06 MB 100.0% 198x Byte[]
206+ └─ 19.95 MB 99.5% 197x Program.Main lambda
207+ ```
208+
209+ ### --exception
210+ Exception profiling with thrown counts, throw‑site call tree, and optional catch‑site table/tree.
211+ Use ` --exception-type ` to focus on a specific exception.
212+
213+ Example (examples/exception):
214+ ``` bash
215+ dotnet build -c Release examples/exception/ExceptionDemo.csproj
216+ asynkron-profiler --exception --exception-type " InvalidOperation" -- ./examples/exception/bin/Release/net10.0/ExceptionDemo
217+ ```
218+
219+ Sample output (top of call tree):
220+ ```
221+ Call Tree (Thrown Exceptions)
222+ 6,667x 100.0% InvalidOperationException
223+ └─ 6,667x 100.0% Program.Main lambda
224+ └─ 6,667x 100.0% EH.DispatchEx
225+ ```
226+
227+ ### --contention
228+ Lock contention profiling with wait‑time call tree and top contended methods.
229+ Use this to find where threads are blocking on locks.
230+
231+ Example (examples/contention):
232+ ``` bash
233+ dotnet build -c Release examples/contention/ContentionDemo.csproj
234+ asynkron-profiler --contention -- ./examples/contention/bin/Release/net10.0/ContentionDemo
235+ ```
236+
237+ Sample output (top of call tree):
238+ ```
239+ Call Tree (Wait Time)
240+ 49563.89 ms 100.0% 96x Total
241+ └─ 49563.89 ms 100.0% 96x Program.RunWorkers lambda
242+ └─ 49563.89 ms 100.0% 96x Program.WorkWithLock
243+ ```
244+
245+ ### --heap
246+ Heap snapshot using ` dotnet-gcdump ` , with a summary of top types.
247+ Use this to inspect retained memory after the run.
248+
249+ Example (examples/heap):
250+ ``` bash
251+ dotnet build -c Release examples/heap/HeapDemo.csproj
252+ asynkron-profiler --heap -- ./examples/heap/bin/Release/net8.0/HeapDemo
253+ ```
254+
255+ Sample output (top types):
256+ ```
257+ HEAP SNAPSHOT: HeapDemo
258+ 14,595,494 GC Heap bytes
259+ 50,375 GC Heap objects
260+
261+ Object Bytes Count Type
262+ 524,312 1 System.Byte[][] (Bytes > 100K)
263+ 30,168 1 System.String (Bytes > 10K)
264+ 24 50,003 System.Byte[]
265+ ```
266+
169267## Troubleshooting
170268
171269- ` dotnet-trace ` not found: install with ` dotnet tool install -g dotnet-trace ` and ensure your global tool path is on ` PATH ` .
0 commit comments