profiler-md 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/cli/index.mjs +5512 -2297
  2. package/dist/index.d.mts +974 -62
  3. package/dist/index.js +2 -2
  4. package/docs/formats/jfr.md +16 -0
  5. package/docs/formats/jsc-heap-snapshot.md +3 -3
  6. package/docs/formats/pprof.md +8 -6
  7. package/docs/formats/speedscope.md +5 -4
  8. package/docs/formats/systing.md +25 -0
  9. package/docs/formats/v8-heap-snapshot.md +2 -2
  10. package/docs/languages/c.md +66 -9
  11. package/docs/languages/csharp.md +4 -3
  12. package/docs/languages/elixir.md +10 -7
  13. package/docs/languages/go.md +17 -12
  14. package/docs/languages/java.md +110 -60
  15. package/docs/languages/javascript.md +41 -19
  16. package/docs/languages/julia.md +103 -12
  17. package/docs/languages/php.md +63 -20
  18. package/docs/languages/python.md +35 -81
  19. package/docs/languages/ruby.md +20 -32
  20. package/docs/languages/rust.md +37 -8
  21. package/examples/output/c.gperftools.cpu.base.pprof.md +324 -0
  22. package/examples/output/c.gperftools.cpu.current.pprof.md +271 -0
  23. package/examples/output/c.gperftools.cpu.diff.pprof.md +98 -0
  24. package/examples/output/c.gperftools.heap.base.pprof.md +362 -0
  25. package/examples/output/c.gperftools.heap.current.pprof.md +362 -0
  26. package/examples/output/c.gperftools.heap.diff.pprof.md +28 -0
  27. package/examples/output/c.systing.cpu.base.systing.md +824 -0
  28. package/examples/output/c.systing.cpu.current.systing.md +825 -0
  29. package/examples/output/c.systing.cpu.diff.systing.md +238 -0
  30. package/examples/output/cpp.gperftools.cpu.base.pprof.md +557 -0
  31. package/examples/output/cpp.gperftools.cpu.current.pprof.md +573 -0
  32. package/examples/output/cpp.gperftools.cpu.diff.pprof.md +122 -0
  33. package/examples/output/cpp.gperftools.heap.base.pprof.md +67 -0
  34. package/examples/output/cpp.gperftools.heap.current.pprof.md +67 -0
  35. package/examples/output/cpp.gperftools.heap.diff.pprof.md +19 -0
  36. package/examples/output/csharp.dotnet-trace.base.speedscope.json.md +411 -0
  37. package/examples/output/csharp.dotnet-trace.current.speedscope.json.md +412 -0
  38. package/examples/output/csharp.dotnet-trace.diff.speedscope.json.md +122 -0
  39. package/examples/output/elixir.eflambe.cpu.base.collapsed.md +399 -0
  40. package/examples/output/elixir.eflambe.cpu.current.collapsed.md +398 -0
  41. package/examples/output/elixir.eflambe.cpu.diff.collapsed.md +92 -0
  42. package/examples/output/erlang.eflambe.cpu.base.collapsed.md +147 -0
  43. package/examples/output/erlang.eflambe.cpu.current.collapsed.md +147 -0
  44. package/examples/output/erlang.eflambe.cpu.diff.collapsed.md +18 -0
  45. package/examples/output/fsharp.dotnet-trace.base.speedscope.json.md +324 -0
  46. package/examples/output/fsharp.dotnet-trace.current.speedscope.json.md +314 -0
  47. package/examples/output/fsharp.dotnet-trace.diff.speedscope.json.md +119 -0
  48. package/examples/output/go.pprof.block.base.pprof.md +86 -0
  49. package/examples/output/go.pprof.block.current.pprof.md +83 -0
  50. package/examples/output/go.pprof.block.diff.pprof.md +42 -0
  51. package/examples/output/go.pprof.cpu.base.pprof.md +81 -0
  52. package/examples/output/go.pprof.cpu.current.pprof.md +70 -0
  53. package/examples/output/go.pprof.cpu.diff.pprof.md +52 -0
  54. package/examples/output/go.pprof.goroutine.base.pprof.md +43 -0
  55. package/examples/output/go.pprof.goroutine.current.pprof.md +43 -0
  56. package/examples/output/go.pprof.goroutine.diff.pprof.md +13 -0
  57. package/examples/output/go.pprof.heap-alloc.base.pprof.md +154 -0
  58. package/examples/output/go.pprof.heap-alloc.current.pprof.md +146 -0
  59. package/examples/output/go.pprof.heap-alloc.diff.pprof.md +67 -0
  60. package/examples/output/go.pprof.heap.base.pprof.md +154 -0
  61. package/examples/output/go.pprof.heap.current.pprof.md +146 -0
  62. package/examples/output/go.pprof.heap.diff.pprof.md +67 -0
  63. package/examples/output/go.pprof.mutex.base.pprof.md +55 -0
  64. package/examples/output/go.pprof.mutex.current.pprof.md +41 -0
  65. package/examples/output/go.pprof.mutex.diff.pprof.md +31 -0
  66. package/examples/output/go.pprof.threadcreate.base.pprof.md +55 -0
  67. package/examples/output/go.pprof.threadcreate.current.pprof.md +55 -0
  68. package/examples/output/go.pprof.threadcreate.diff.pprof.md +19 -0
  69. package/examples/output/java.async-profiler.all.base.jfr.md +1071 -0
  70. package/examples/output/java.async-profiler.all.current.jfr.md +1007 -0
  71. package/examples/output/java.async-profiler.all.diff.jfr.md +268 -0
  72. package/examples/output/java.async-profiler.alloc.base.jfr.md +425 -0
  73. package/examples/output/java.async-profiler.alloc.current.jfr.md +413 -0
  74. package/examples/output/java.async-profiler.alloc.diff.jfr.md +99 -0
  75. package/examples/output/java.async-profiler.cpu.base.collapsed.md +367 -0
  76. package/examples/output/java.async-profiler.cpu.base.jfr.md +485 -0
  77. package/examples/output/java.async-profiler.cpu.current.collapsed.md +355 -0
  78. package/examples/output/java.async-profiler.cpu.current.jfr.md +488 -0
  79. package/examples/output/java.async-profiler.cpu.diff.collapsed.md +117 -0
  80. package/examples/output/java.async-profiler.cpu.diff.jfr.md +118 -0
  81. package/examples/output/java.async-profiler.live.base.jfr.md +697 -0
  82. package/examples/output/java.async-profiler.live.current.jfr.md +684 -0
  83. package/examples/output/java.async-profiler.live.diff.jfr.md +191 -0
  84. package/examples/output/java.async-profiler.lock.base.jfr.md +140 -0
  85. package/examples/output/java.async-profiler.lock.current.jfr.md +108 -0
  86. package/examples/output/java.async-profiler.lock.diff.jfr.md +44 -0
  87. package/examples/output/java.async-profiler.nativemem.base.jfr.md +222 -0
  88. package/examples/output/java.async-profiler.nativemem.current.jfr.md +222 -0
  89. package/examples/output/java.async-profiler.nativemem.diff.jfr.md +65 -0
  90. package/examples/output/java.async-profiler.wall.base.jfr.md +400 -0
  91. package/examples/output/java.async-profiler.wall.current.jfr.md +420 -0
  92. package/examples/output/java.async-profiler.wall.diff.jfr.md +94 -0
  93. package/examples/output/java.jdk.all.base.jfr.md +1024 -0
  94. package/examples/output/java.jdk.all.current.jfr.md +1010 -0
  95. package/examples/output/java.jdk.all.diff.jfr.md +311 -0
  96. package/examples/output/java.jdk.alloc.base.jfr.md +1024 -0
  97. package/examples/output/java.jdk.alloc.current.jfr.md +1046 -0
  98. package/examples/output/java.jdk.alloc.diff.jfr.md +312 -0
  99. package/examples/output/java.jdk.cpu.base.jfr.md +1023 -0
  100. package/examples/output/java.jdk.cpu.current.jfr.md +1039 -0
  101. package/examples/output/java.jdk.cpu.diff.jfr.md +285 -0
  102. package/examples/output/java.jdk.live.base.jfr.md +1029 -0
  103. package/examples/output/java.jdk.live.current.jfr.md +1035 -0
  104. package/examples/output/java.jdk.live.diff.jfr.md +289 -0
  105. package/examples/output/java.jdk.lock.base.jfr.md +1040 -0
  106. package/examples/output/java.jdk.lock.current.jfr.md +1051 -0
  107. package/examples/output/java.jdk.lock.diff.jfr.md +339 -0
  108. package/examples/output/javascript.bun.base.cpuprofile.md +73 -0
  109. package/examples/output/javascript.bun.base.heapsnapshot.md +608 -0
  110. package/examples/output/javascript.bun.base.jsc-heap-snapshot.json.md +480 -0
  111. package/examples/output/javascript.bun.current.cpuprofile.md +73 -0
  112. package/examples/output/javascript.bun.current.heapsnapshot.md +608 -0
  113. package/examples/output/javascript.bun.current.jsc-heap-snapshot.json.md +480 -0
  114. package/examples/output/javascript.bun.diff.cpuprofile.md +54 -0
  115. package/examples/output/javascript.bun.diff.heapsnapshot.md +48 -0
  116. package/examples/output/javascript.bun.diff.jsc-heap-snapshot.json.md +62 -0
  117. package/examples/output/javascript.chrome.base.cpuprofile.md +163 -0
  118. package/examples/output/javascript.chrome.base.heapprofile.md +32 -0
  119. package/examples/output/javascript.chrome.base.heapsnapshot.md +649 -0
  120. package/examples/output/javascript.chrome.current.cpuprofile.md +149 -0
  121. package/examples/output/javascript.chrome.current.heapprofile.md +32 -0
  122. package/examples/output/javascript.chrome.current.heapsnapshot.md +647 -0
  123. package/examples/output/javascript.chrome.diff.cpuprofile.md +65 -0
  124. package/examples/output/javascript.chrome.diff.heapprofile.md +50 -0
  125. package/examples/output/javascript.chrome.diff.heapsnapshot.md +73 -0
  126. package/examples/output/javascript.deno.base.cpuprofile.md +122 -0
  127. package/examples/output/javascript.deno.current.cpuprofile.md +114 -0
  128. package/examples/output/javascript.deno.diff.cpuprofile.md +66 -0
  129. package/examples/output/javascript.node.base.cpuprofile.md +136 -0
  130. package/examples/output/javascript.node.base.heapprofile.md +56 -0
  131. package/examples/output/javascript.node.base.heapsnapshot.md +660 -0
  132. package/examples/output/javascript.node.current.cpuprofile.md +119 -0
  133. package/examples/output/javascript.node.current.heapprofile.md +52 -0
  134. package/examples/output/javascript.node.current.heapsnapshot.md +660 -0
  135. package/examples/output/javascript.node.diff.cpuprofile.md +70 -0
  136. package/examples/output/javascript.node.diff.heapprofile.md +34 -0
  137. package/examples/output/javascript.node.diff.heapsnapshot.md +39 -0
  138. package/examples/output/javascript.pprof.cpu.base.pprof.md +104 -0
  139. package/examples/output/javascript.pprof.cpu.current.pprof.md +120 -0
  140. package/examples/output/javascript.pprof.cpu.diff.pprof.md +63 -0
  141. package/examples/output/javascript.pprof.heap.base.pprof.md +86 -0
  142. package/examples/output/javascript.pprof.heap.current.pprof.md +57 -0
  143. package/examples/output/javascript.pprof.heap.diff.pprof.md +42 -0
  144. package/examples/output/javascript.safari.base.webkit-timeline-recording.json.md +388 -0
  145. package/examples/output/javascript.safari.current.webkit-timeline-recording.json.md +378 -0
  146. package/examples/output/javascript.safari.diff.webkit-timeline-recording.json.md +122 -0
  147. package/examples/output/julia.pprof-jl.alloc.base.pprof.md +124 -0
  148. package/examples/output/julia.pprof-jl.alloc.current.pprof.md +126 -0
  149. package/examples/output/julia.pprof-jl.alloc.diff.pprof.md +30 -0
  150. package/examples/output/julia.pprof-jl.cpu.base.pprof.md +177 -0
  151. package/examples/output/julia.pprof-jl.cpu.current.pprof.md +179 -0
  152. package/examples/output/julia.pprof-jl.cpu.diff.pprof.md +64 -0
  153. package/examples/output/julia.pprof-jl.wall.base.pprof.md +181 -0
  154. package/examples/output/julia.pprof-jl.wall.current.pprof.md +193 -0
  155. package/examples/output/julia.pprof-jl.wall.diff.pprof.md +64 -0
  156. package/examples/output/julia.profile.base.heapsnapshot.md +590 -0
  157. package/examples/output/julia.profile.current.heapsnapshot.md +590 -0
  158. package/examples/output/julia.profile.diff.heapsnapshot.md +288 -0
  159. package/examples/output/kotlin.async-profiler.all.base.jfr.md +920 -0
  160. package/examples/output/kotlin.async-profiler.all.current.jfr.md +925 -0
  161. package/examples/output/kotlin.async-profiler.all.diff.jfr.md +247 -0
  162. package/examples/output/kotlin.async-profiler.alloc.base.jfr.md +467 -0
  163. package/examples/output/kotlin.async-profiler.alloc.current.jfr.md +473 -0
  164. package/examples/output/kotlin.async-profiler.alloc.diff.jfr.md +122 -0
  165. package/examples/output/kotlin.async-profiler.cpu.base.collapsed.md +371 -0
  166. package/examples/output/kotlin.async-profiler.cpu.base.jfr.md +472 -0
  167. package/examples/output/kotlin.async-profiler.cpu.current.collapsed.md +370 -0
  168. package/examples/output/kotlin.async-profiler.cpu.current.jfr.md +445 -0
  169. package/examples/output/kotlin.async-profiler.cpu.diff.collapsed.md +124 -0
  170. package/examples/output/kotlin.async-profiler.cpu.diff.jfr.md +125 -0
  171. package/examples/output/kotlin.async-profiler.live.base.jfr.md +934 -0
  172. package/examples/output/kotlin.async-profiler.live.current.jfr.md +917 -0
  173. package/examples/output/kotlin.async-profiler.live.diff.jfr.md +245 -0
  174. package/examples/output/kotlin.async-profiler.lock.base.jfr.md +1 -0
  175. package/examples/output/kotlin.async-profiler.lock.current.jfr.md +1 -0
  176. package/examples/output/kotlin.async-profiler.lock.diff.jfr.md +1 -0
  177. package/examples/output/kotlin.async-profiler.nativemem.base.jfr.md +234 -0
  178. package/examples/output/kotlin.async-profiler.nativemem.current.jfr.md +234 -0
  179. package/examples/output/kotlin.async-profiler.nativemem.diff.jfr.md +65 -0
  180. package/examples/output/kotlin.async-profiler.wall.base.jfr.md +452 -0
  181. package/examples/output/kotlin.async-profiler.wall.current.jfr.md +457 -0
  182. package/examples/output/kotlin.async-profiler.wall.diff.jfr.md +125 -0
  183. package/examples/output/kotlin.jdk.all.base.jfr.md +1442 -0
  184. package/examples/output/kotlin.jdk.all.current.jfr.md +1343 -0
  185. package/examples/output/kotlin.jdk.all.diff.jfr.md +392 -0
  186. package/examples/output/kotlin.jdk.alloc.base.jfr.md +1418 -0
  187. package/examples/output/kotlin.jdk.alloc.current.jfr.md +1389 -0
  188. package/examples/output/kotlin.jdk.alloc.diff.jfr.md +383 -0
  189. package/examples/output/kotlin.jdk.cpu.base.jfr.md +1406 -0
  190. package/examples/output/kotlin.jdk.cpu.current.jfr.md +1374 -0
  191. package/examples/output/kotlin.jdk.cpu.diff.jfr.md +380 -0
  192. package/examples/output/kotlin.jdk.live.base.jfr.md +1378 -0
  193. package/examples/output/kotlin.jdk.live.current.jfr.md +1311 -0
  194. package/examples/output/kotlin.jdk.live.diff.jfr.md +381 -0
  195. package/examples/output/kotlin.jdk.lock.base.jfr.md +1427 -0
  196. package/examples/output/kotlin.jdk.lock.current.jfr.md +1374 -0
  197. package/examples/output/kotlin.jdk.lock.diff.jfr.md +386 -0
  198. package/examples/output/php.excimer.wall.base.speedscope.json.md +25 -0
  199. package/examples/output/php.excimer.wall.current.speedscope.json.md +25 -0
  200. package/examples/output/php.excimer.wall.diff.speedscope.json.md +29 -0
  201. package/examples/output/python.py-spy.cpu.base.collapsed.md +526 -0
  202. package/examples/output/python.py-spy.cpu.base.speedscope.json.md +37 -0
  203. package/examples/output/python.py-spy.cpu.current.collapsed.md +514 -0
  204. package/examples/output/python.py-spy.cpu.current.speedscope.json.md +37 -0
  205. package/examples/output/python.py-spy.cpu.diff.collapsed.md +122 -0
  206. package/examples/output/python.py-spy.cpu.diff.speedscope.json.md +31 -0
  207. package/examples/output/python.py-spy.wall.base.collapsed.md +527 -0
  208. package/examples/output/python.py-spy.wall.current.collapsed.md +518 -0
  209. package/examples/output/python.py-spy.wall.diff.collapsed.md +122 -0
  210. package/examples/output/ruby.rbspy.cpu.base.collapsed.md +90 -0
  211. package/examples/output/ruby.rbspy.cpu.base.pprof.md +105 -0
  212. package/examples/output/ruby.rbspy.cpu.base.speedscope.json.md +105 -0
  213. package/examples/output/ruby.rbspy.cpu.current.collapsed.md +90 -0
  214. package/examples/output/ruby.rbspy.cpu.current.pprof.md +115 -0
  215. package/examples/output/ruby.rbspy.cpu.current.speedscope.json.md +115 -0
  216. package/examples/output/ruby.rbspy.cpu.diff.collapsed.md +32 -0
  217. package/examples/output/ruby.rbspy.cpu.diff.pprof.md +44 -0
  218. package/examples/output/ruby.rbspy.cpu.diff.speedscope.json.md +44 -0
  219. package/examples/output/rust.pprof-rs.cpu.base.pprof.md +60 -0
  220. package/examples/output/rust.pprof-rs.cpu.current.pprof.md +60 -0
  221. package/examples/output/rust.pprof-rs.cpu.diff.pprof.md +24 -0
  222. package/package.json +17 -12
  223. package/readme.md +158 -48
  224. package/skills/profile-optimize/SKILL.md +160 -0
  225. package/docs/languages/cpp.md +0 -136
  226. package/docs/languages/erlang.md +0 -42
  227. package/docs/languages/fsharp.md +0 -49
  228. package/docs/languages/kotlin.md +0 -120
  229. package/docs/languages/typescript.md +0 -254
  230. package/examples/bun.cpuprofile.md +0 -475
  231. package/examples/deno.cpuprofile.md +0 -481
  232. package/examples/jsc-heap-snapshot.base.json.md +0 -507
  233. package/examples/jsc-heap-snapshot.current.json.md +0 -504
  234. package/examples/jsc-heap-snapshot.diff.json.md +0 -119
  235. package/examples/node.base.cpuprofile.md +0 -451
  236. package/examples/node.current.cpuprofile.md +0 -449
  237. package/examples/node.diff.cpuprofile.md +0 -82
  238. package/examples/node.heapprofile.md +0 -281
  239. package/examples/node.heapsnapshot.md +0 -694
  240. package/examples/node.pprof.md +0 -441
  241. package/examples/python.base.collapsed.md +0 -116
  242. package/examples/python.current.collapsed.md +0 -125
  243. package/examples/python.diff.collapsed.md +0 -51
  244. package/examples/rust.base.pprof.md +0 -477
  245. package/examples/rust.current.pprof.md +0 -480
  246. package/examples/rust.diff.pprof.md +0 -117
  247. package/examples/webkit-timeline-recording.json.md +0 -434
@@ -1,136 +0,0 @@
1
- # C/C++
2
-
3
- C and C++ profiling uses [gperftools](https://github.com/gperftools/gperftools).
4
-
5
- ## CPU profiling
6
-
7
- Periodically samples the call stack. Useful for finding CPU hot spots.
8
-
9
- Link with `-lprofiler`:
10
-
11
- ```sh
12
- gcc -O2 -lprofiler -o program program.c # C
13
- g++ -O2 -lprofiler -o program program.cpp # C++
14
- ```
15
-
16
- ### CLI
17
-
18
- ```sh
19
- # Generate a CPU profile
20
- CPUPROFILE=cpu.prof ./program
21
-
22
- # Convert to pprof protobuf format
23
- pprof --proto ./program cpu.prof > cpu.pprof
24
- ```
25
-
26
- #### Environment variables
27
-
28
- | Variable | Default | Description |
29
- | ---------------------- | ------- | -------------------------------------------------------------------------------- |
30
- | `CPUPROFILE` | — | Output filename; profiling is enabled when set |
31
- | `CPUPROFILE_FREQUENCY` | `100` | Samples per second |
32
- | `CPUPROFILE_REALTIME` | — | Use wall-clock time (`ITIMER_REAL`) instead of CPU time (`ITIMER_PROF`) when set |
33
- | `CPUPROFILESIGNAL` | — | Signal number to toggle profiling on/off at runtime |
34
-
35
- ### Programmatic API
36
-
37
- ```c
38
- #include <gperftools/profiler.h>
39
-
40
- ProfilerStart("cpu.prof");
41
-
42
- // Code to profile...
43
-
44
- ProfilerFlush(); // optional: flush buffered samples mid-run
45
- ProfilerStop();
46
- ```
47
-
48
- ## Memory profiling
49
-
50
- Periodically dumps the live heap, capturing allocation stack traces. Useful for
51
- finding memory leaks and allocation hot spots.
52
-
53
- Link with `-ltcmalloc`:
54
-
55
- ```sh
56
- gcc -O2 -ltcmalloc -o program program.c # C
57
- g++ -O2 -ltcmalloc -o program program.cpp # C++
58
- ```
59
-
60
- ### CLI
61
-
62
- ```sh
63
- # Generate heap profiles (written as <prefix>.0000.heap, .0001.heap, …)
64
- HEAPPROFILE=heap.prof ./program
65
-
66
- # Convert a heap profile to pprof protobuf format
67
- pprof --proto ./program heap.prof.0001.heap > heap.pprof
68
- ```
69
-
70
- #### Environment variables
71
-
72
- | Variable | Default | Description |
73
- | ---------------------------------- | ------------ | --------------------------------------------------------------------------------------------- |
74
- | `HEAPPROFILE` | — | Output filename prefix; heap profiling is enabled when set |
75
- | `HEAP_PROFILE_ALLOCATION_INTERVAL` | `1073741824` | Dump a profile after every this many bytes allocated (default 1 GB) |
76
- | `HEAP_PROFILE_INUSE_INTERVAL` | `104857600` | Dump a profile each time the in-use high-water mark grows by this many bytes (default 100 MB) |
77
- | `HEAP_PROFILE_TIME_INTERVAL` | `0` | Dump a profile every this many seconds (disabled by default) |
78
- | `HEAPPROFILESIGNAL` | — | Signal number to dump a profile on demand |
79
- | `HEAP_PROFILE_MMAP` | `false` | Also profile `mmap`/`mremap`/`sbrk` calls |
80
- | `HEAP_PROFILE_ONLY_MMAP` | `false` | Profile only `mmap`/`mremap`/`sbrk`; skip `malloc`/`new` |
81
-
82
- ### Programmatic API
83
-
84
- ```c
85
- #include <gperftools/heap-profiler.h>
86
-
87
- HeapProfilerStart("heap.prof");
88
-
89
- // Code to profile...
90
-
91
- HeapProfilerDump("checkpoint"); // optional mid-run profile dump
92
- HeapProfilerStop();
93
- ```
94
-
95
- ## Heap checking
96
-
97
- Compares the heap state before and after a region of code to detect memory
98
- leaks. Useful for confirming that a code path frees everything it allocates.
99
-
100
- Link with `-ltcmalloc`:
101
-
102
- ```sh
103
- gcc -O2 -ltcmalloc -o program program.c # C
104
- g++ -O2 -ltcmalloc -o program program.cpp # C++
105
- ```
106
-
107
- ### CLI
108
-
109
- ```sh
110
- # Report leaks at program exit
111
- HEAPCHECK=normal ./program
112
-
113
- # Also report still-reachable allocations at exit
114
- HEAPCHECK=strict ./program
115
-
116
- # Most aggressive: report all live allocations at exit
117
- HEAPCHECK=draconian ./program
118
- ```
119
-
120
- #### Environment variables
121
-
122
- | Variable | Default | Description |
123
- | ----------- | ------- | ------------------------------------------------------------------------------------ |
124
- | `HEAPCHECK` | — | Leak-checking mode (`minimal`, `normal`, `strict`, or `draconian`); enabled when set |
125
-
126
- ### Programmatic API
127
-
128
- ```c
129
- #include <gperftools/heap-checker.h>
130
-
131
- HeapLeakChecker checker("my_check");
132
-
133
- // Code to check...
134
-
135
- if (!checker.NoLeaks()) abort(); // fails if any net allocations were not freed
136
- ```
@@ -1,42 +0,0 @@
1
- # Elixir/Erlang
2
-
3
- Elixir and Erlang profiling uses
4
- [eflambe](https://github.com/Stratus3D/eflambe), a profiler for the BEAM that
5
- wraps the runtime's built-in tracing and writes flame graph output.
6
-
7
- ## CPU profiling
8
-
9
- Traces function calls and writes them as collapsed stacks. Useful for finding
10
- CPU hot spots.
11
-
12
- eflambe's default `brendan_gregg` output format is collapsed stacks. Add
13
- `eflambe` to your dependencies, then profile a specific function.
14
-
15
- ### Elixir
16
-
17
- ```elixir
18
- # Profile a function as it runs during normal execution (capture 1 call)
19
- :eflambe.capture({MyModule, :my_function, 1}, 1, output_format: :brendan_gregg)
20
-
21
- # Directly invoke and profile a function
22
- :eflambe.apply({MyModule, :my_function, [arg1, arg2]}, output_format: :brendan_gregg)
23
- ```
24
-
25
- ### Erlang
26
-
27
- ```erlang
28
- %% Profile a function as it runs during normal execution (capture 1 call)
29
- eflambe:capture({my_module, my_function, 1}, 1, [{output_format, brendan_gregg}]).
30
-
31
- %% Directly invoke and profile a function
32
- eflambe:apply({my_module, my_function, [Arg1, Arg2]}, [{output_format, brendan_gregg}]).
33
- ```
34
-
35
- ### Options
36
-
37
- | Option | Default | Description |
38
- | ------------------ | --------------- | --------------------------------------------------- |
39
- | `output_format` | `brendan_gregg` | Output format: `brendan_gregg` (collapsed) or `svg` |
40
- | `output_directory` | project root | Directory to write the output file to |
41
- | `open` | — | Auto-open the result in `speedscope` or `hotspot` |
42
- | `return` | `filename` | Return value: `value`, `flamegraph`, or `filename` |
@@ -1,49 +0,0 @@
1
- # C#/F#
2
-
3
- .NET profiling (C#, F#, and other CLR languages) uses
4
- [`dotnet-trace`](https://learn.microsoft.com/dotnet/core/diagnostics/dotnet-trace),
5
- a cross-platform diagnostics tool that collects traces through the runtime's
6
- EventPipe without a native profiler.
7
-
8
- Install it as a global tool:
9
-
10
- ```sh
11
- dotnet tool install --global dotnet-trace
12
- ```
13
-
14
- ## CPU profiling
15
-
16
- Periodically samples the call stack. Useful for finding CPU hot spots.
17
-
18
- With no `--profile` or `--providers`, `dotnet-trace collect` enables the
19
- `dotnet-common` and `dotnet-sampled-thread-time` profiles, sampling thread
20
- stacks at roughly 100 Hz.
21
-
22
- ### CLI
23
-
24
- ```sh
25
- # Attach to a running process, written directly as speedscope
26
- dotnet-trace collect --process-id <pid> --format speedscope
27
-
28
- # Launch and trace a command from startup (use `dotnet exec` so the dotnet CLI's
29
- # own child processes aren't traced instead of your app)
30
- dotnet-trace collect --format speedscope -- dotnet exec app.dll
31
-
32
- # Attach for a fixed duration (dd:hh:mm:ss)
33
- dotnet-trace collect --process-id <pid> --duration 00:00:00:30 --format speedscope
34
-
35
- # Convert an existing .nettrace to speedscope
36
- dotnet-trace convert trace.nettrace --format speedscope
37
- ```
38
-
39
- #### Flags
40
-
41
- | Flag | Default | Description |
42
- | --------------------- | ---------- | --------------------------------------------------- |
43
- | `-p` / `--process-id` | — | PID of the process to trace |
44
- | `-n` / `--name` | — | Name of the process to trace |
45
- | `--duration` | — | Duration to run, in `dd:hh:mm:ss` format |
46
- | `-o` / `--output` | `nettrace` | Output file path |
47
- | `--format` | `nettrace` | Output format: `nettrace`, `speedscope`, `chromium` |
48
- | `--profile` | — | Preset provider configuration (e.g. `gc-verbose`) |
49
- | `--providers` | — | Comma-separated EventPipe providers to enable |
@@ -1,120 +0,0 @@
1
- # Java/Kotlin
2
-
3
- Java and Kotlin profiling uses
4
- [async-profiler](https://github.com/async-profiler/async-profiler), a low
5
- overhead sampling profiler that works with any JVM language.
6
-
7
- ## CPU profiling
8
-
9
- Periodically samples the call stack. Useful for finding CPU hot spots.
10
-
11
- ### CLI
12
-
13
- ```sh
14
- # Attach to a running process (collapsed format)
15
- asprof -d 30 -f cpu.collapsed -o collapsed <pid>
16
-
17
- # Attach to a running process (pprof format)
18
- asprof -d 30 -f cpu.pprof <pid>
19
-
20
- # Attach to a running process (speedscope format)
21
- asprof -d 30 -f profile.speedscope -o speedscope <pid>
22
-
23
- # Profile a command directly
24
- asprof -d 30 -f cpu.pprof -- java -jar app.jar
25
- ```
26
-
27
- ### Programmatic API
28
-
29
- Add `async-profiler` to your dependencies, then:
30
-
31
- ```java
32
- import one.profiler.AsyncProfiler;
33
-
34
- AsyncProfiler profiler = AsyncProfiler.getInstance();
35
- profiler.execute("start,event=cpu,file=cpu.jfr");
36
-
37
- // Code to profile...
38
-
39
- profiler.execute("stop");
40
- ```
41
-
42
- ## Wall-clock profiling
43
-
44
- Samples wall-clock time rather than CPU time. Useful for I/O-bound or
45
- latency-sensitive code where threads spend time waiting.
46
-
47
- ### CLI
48
-
49
- ```sh
50
- asprof -d 30 -e wall -f profile.pprof <pid>
51
- ```
52
-
53
- ### Programmatic API
54
-
55
- ```java
56
- AsyncProfiler profiler = AsyncProfiler.getInstance();
57
- profiler.execute("start,event=wall,file=profile.jfr");
58
-
59
- // Code to profile...
60
-
61
- profiler.execute("stop");
62
- ```
63
-
64
- ## Memory profiling
65
-
66
- Samples heap allocations. Useful for finding allocation hot spots and reducing
67
- GC pressure.
68
-
69
- ### CLI
70
-
71
- ```sh
72
- # Attach to a running process (pprof format)
73
- asprof -d 30 -e alloc -f mem.pprof <pid>
74
-
75
- # Profile a command directly
76
- asprof -d 30 -e alloc -f mem.pprof -- java -jar app.jar
77
- ```
78
-
79
- ### Programmatic API
80
-
81
- ```java
82
- AsyncProfiler profiler = AsyncProfiler.getInstance();
83
- profiler.execute("start,event=alloc,file=mem.jfr");
84
-
85
- // Code to profile...
86
-
87
- profiler.execute("stop");
88
- ```
89
-
90
- ## Lock profiling
91
-
92
- Samples contended monitor locks (`synchronized`, `ReentrantLock`, and other
93
- `java.util.concurrent` locks). Useful for finding lock contention hot spots.
94
-
95
- ### CLI
96
-
97
- ```sh
98
- asprof -d 30 -e lock -f lock.pprof <pid>
99
- ```
100
-
101
- ### Programmatic API
102
-
103
- ```java
104
- AsyncProfiler profiler = AsyncProfiler.getInstance();
105
- profiler.execute("start,event=lock,file=lock.jfr");
106
-
107
- // Code to profile...
108
-
109
- profiler.execute("stop");
110
- ```
111
-
112
- ## CLI flags
113
-
114
- | Flag | Default | Description |
115
- | ------------------- | ------- | -------------------------------------------------------- |
116
- | `-d` / `--duration` | — | Duration in seconds |
117
- | `-e` / `--event` | `cpu` | Event to profile: `cpu`, `wall`, `alloc`, `lock` |
118
- | `-f` / `--file` | — | Output file path |
119
- | `-o` / `--output` | `jfr` | Output format: `collapsed`, `jfr`, `pprof`, `speedscope` |
120
- | `-i` / `--interval` | `10ms` | Sampling interval (e.g. `-i 1ms` for 1000 Hz) |
@@ -1,254 +0,0 @@
1
- # JavaScript
2
-
3
- Profiling JavaScript works across Node.js, Deno, Bun, and Chrome via V8 CPU
4
- profiles, V8 heap profiles, and V8 heap snapshots.
5
-
6
- ## CPU profiling
7
-
8
- Periodically samples the call stack. Useful for finding CPU hot spots.
9
-
10
- ### CLI
11
-
12
- ```sh
13
- # Node.js
14
- node --cpu-prof script.js
15
-
16
- # Deno
17
- deno run --cpu-prof script.ts
18
-
19
- # Bun (output was incorrect before v1.3.13)
20
- bun --cpu-prof script.ts
21
- ```
22
-
23
- #### Flags
24
-
25
- | Flag | Default | Description |
26
- | -------------------------- | ---------------------------------- | --------------------------------------------- |
27
- | `--cpu-prof` | — | Write a CPU profile on exit; enabled when set |
28
- | `--cpu-prof-interval=<µs>` | `1000` | Sampling interval in microseconds |
29
- | `--cpu-prof-dir=<dir>` | `.` | Directory to write the profile to |
30
- | `--cpu-prof-name=<name>` | `CPU.<timestamp>.<pid>.cpuprofile` | Filename for the profile |
31
-
32
- ### Programmatic API
33
-
34
- Profile a specific section of code rather than the whole process:
35
-
36
- ```js
37
- import { writeFileSync } from 'node:fs'
38
- import { Session } from 'node:inspector/promises'
39
-
40
- const session = new Session()
41
- session.connect()
42
- await session.post(`Profiler.enable`)
43
- await session.post(`Profiler.setSamplingInterval`, { interval: 100 })
44
- await session.post(`Profiler.start`)
45
-
46
- // Code to profile...
47
-
48
- const { profile } = await session.post(`Profiler.stop`)
49
- writeFileSync(`cpu.cpuprofile`, JSON.stringify(profile))
50
- ```
51
-
52
- ## Memory profiling
53
-
54
- Samples heap allocations by stack trace. Useful for finding allocation hot spots
55
- and reducing GC pressure.
56
-
57
- `bun --heap-prof` generates a heap _snapshot_ on exit, not a heap _profile_.
58
- Deno has no equivalent.
59
-
60
- ### CLI
61
-
62
- ```sh
63
- # Node.js
64
- node --heap-prof script.js
65
- ```
66
-
67
- #### Flags
68
-
69
- | Flag | Default | Description |
70
- | ------------------------------ | -------- | ---------------------------------------------- |
71
- | `--heap-prof` | — | Write a heap profile on exit; enabled when set |
72
- | `--heap-prof-interval=<bytes>` | `524288` | Sampling interval in bytes (default 512 KB) |
73
- | `--heap-prof-dir=<dir>` | `.` | Directory to write the profile to |
74
- | `--heap-prof-name=<name>` | — | Filename for the profile |
75
-
76
- ### Programmatic API
77
-
78
- ```js
79
- import { writeFileSync } from 'node:fs'
80
- import { Session } from 'node:inspector/promises'
81
-
82
- const session = new Session()
83
- session.connect()
84
- await session.post(`HeapProfiler.enable`)
85
- await session.post(`HeapProfiler.startSamplingHeapProfiler`, {
86
- samplingInterval: 524_288,
87
- })
88
-
89
- // Code to profile...
90
-
91
- const { profile } = await session.post(`HeapProfiler.stopSamplingHeapProfiler`)
92
- writeFileSync(`heap.heapprofile`, JSON.stringify(profile))
93
- ```
94
-
95
- ## Heap snapshots
96
-
97
- Captures a snapshot of all live objects on the heap. Useful for diagnosing
98
- memory leaks.
99
-
100
- ### CLI
101
-
102
- ```sh
103
- # Trigger on OOM
104
- node --heapsnapshot-near-heap-limit=1 script.js
105
-
106
- # Trigger on signal
107
- node --heapsnapshot-signal=USR2 script.js # then: kill -USR2 <pid>
108
-
109
- # Bun (on exit)
110
- bun --heap-prof script.ts
111
- ```
112
-
113
- #### Node.js flags
114
-
115
- | Flag | Default | Description |
116
- | ------------------------------------ | ------- | ---------------------------------------------------------- |
117
- | `--heapsnapshot-near-heap-limit=<n>` | — | Write up to n snapshots when the heap approaches its limit |
118
- | `--heapsnapshot-signal=<signal>` | — | Signal that triggers a snapshot on demand (e.g. `USR2`) |
119
-
120
- #### Bun flags
121
-
122
- | Flag | Default | Description |
123
- | ------------------------- | ------- | ----------------------------------------------- |
124
- | `--heap-prof` | — | Write a heap snapshot on exit; enabled when set |
125
- | `--heap-prof-dir=<dir>` | `.` | Directory to write the snapshot to |
126
- | `--heap-prof-name=<name>` | — | Filename for the snapshot |
127
-
128
- ### Programmatic API
129
-
130
- ```js
131
- import { writeHeapSnapshot } from 'node:v8'
132
-
133
- // Code to capture...
134
- writeHeapSnapshot(`heap.heapsnapshot`)
135
- ```
136
-
137
- ## pprof
138
-
139
- Node.js can also emit [pprof](https://github.com/google/pprof) profiles via the
140
- [`@datadog/pprof`](https://www.npmjs.com/package/@datadog/pprof) package, which
141
- profiles a section of code rather than the whole process.
142
-
143
- ### CPU profiling
144
-
145
- Samples wall-clock time across all threads. Useful for finding CPU hot spots and
146
- time spent waiting.
147
-
148
- ```js
149
- import { writeFile } from 'node:fs/promises'
150
- import { encode, time } from '@datadog/pprof'
151
-
152
- const profile = await time.profile({ durationMillis: 10_000 })
153
- await writeFile(`cpu.pb.gz`, await encode(profile))
154
- ```
155
-
156
- ### Memory profiling
157
-
158
- Samples heap allocations by stack trace. Useful for finding allocation hot spots
159
- and reducing GC pressure.
160
-
161
- ```js
162
- import { writeFile } from 'node:fs/promises'
163
- import { encode, heap } from '@datadog/pprof'
164
-
165
- heap.start(512 * 1024, 64) // Sampling interval in bytes, max stack depth
166
-
167
- // Code to profile...
168
-
169
- await writeFile(`heap.pb.gz`, await encode(await heap.profile()))
170
- ```
171
-
172
- ## Chrome DevTools
173
-
174
- Chrome DevTools can profile JavaScript running in the browser or connected to
175
- Node.js, Deno, or Bun via `--inspect`. The panels and workflow are the same in
176
- both cases.
177
-
178
- ### Connecting
179
-
180
- **In the browser:** open DevTools with ⌥⌘I (macOS) or Ctrl+Shift+I
181
- (Windows/Linux).
182
-
183
- **Via `--inspect` (Node.js, Deno, Bun):** start the process with the inspector
184
- enabled, then open `chrome://inspect` in Chrome and click **Open dedicated
185
- DevTools for Node**. For Bun, open the URL printed to stderr in
186
- [debug.bun.sh](https://debug.bun.sh) — Bun uses the WebKit Inspector Protocol
187
- rather than V8's.
188
-
189
- ```sh
190
- # Node.js (default port 9229)
191
- node --inspect script.js
192
-
193
- # Deno (default port 9229)
194
- deno run --inspect script.ts
195
-
196
- # Bun (auto-assigned port)
197
- bun --inspect script.ts
198
- ```
199
-
200
- #### Flags (all runtimes)
201
-
202
- | Flag | Description |
203
- | ------------------------------ | ----------------------------------------------------------- |
204
- | `--inspect[=<host:port>]` | Start the inspector; code runs immediately |
205
- | `--inspect-wait[=<host:port>]` | Wait for a debugger to attach before running |
206
- | `--inspect-brk[=<host:port>]` | Wait for a debugger to attach, then break on the first line |
207
-
208
- ### CPU profiling
209
-
210
- Open the **Performance** panel and click **Record**. Stop recording when done.
211
-
212
- ### Heap allocation profiling
213
-
214
- Open the **Memory** panel, select **Allocation sampling**, and click **Start**.
215
- Stop when done to see allocation hot spots by call stack.
216
-
217
- ### Heap snapshots
218
-
219
- Open the **Memory** panel, select **Heap snapshot**, and click **Take
220
- snapshot**.
221
-
222
- ## Safari Web Inspector
223
-
224
- Safari's Web Inspector records a timeline that combines CPU sampling, browser
225
- activity, and optionally memory readings and heap allocations, all exported as a
226
- single file.
227
-
228
- ### Connecting
229
-
230
- Open the Web Inspector with **Develop → Show Web Inspector** (or ⌥⌘I).
231
-
232
- ### Recording
233
-
234
- 1. Click the **Timelines** tab.
235
- 2. Enable the instruments you want: **JavaScript & Events** (always), and
236
- optionally **Memory** and **JavaScript Allocations**.
237
- 3. Click **Start Recording** (or ⌘R).
238
- 4. Reproduce the scenario you want to profile.
239
- 5. Click **Stop Recording**.
240
- 6. Click the **Export** button (arrow icon) and save as a `.json` file.
241
-
242
- ### Heap snapshots
243
-
244
- Open the **Memory** panel, select **Heap Snapshot**, and click **Take
245
- Snapshot**.
246
-
247
- #### Programmatic API
248
-
249
- `console.takeHeapSnapshot()` is a non-standard WebKit extension that takes a
250
- heap snapshot from JavaScript and adds it to the **Memory** panel:
251
-
252
- ```js
253
- console.takeHeapSnapshot()
254
- ```