Lewati ke konten

Pemrofilan & Diagnostik (Profiling & Diagnostics)

Modul pemrofilan menyediakan fasilitas diagnostik V8 bawaan untuk merekam profil CPU, mengambil heap snapshot, dan memeriksa tren pertumbuhan memori. Modul ini terintegrasi dengan sesi inspektor Node.js untuk memungkinkan pengambilan sampel diagnostik runtime tanpa memerlukan restart server. Alat-alat ini membantu operator mendiagnosis regresi performa dan kebocoran memori di bawah beban produksi.

SimbolJenisTanda TanganTujuan
ProfilerConfiginterfaceinterface ProfilerConfigProfiler configuration
ProfileResultinterfaceinterface ProfileResultProfile result
ProfileNodeinterfaceinterface ProfileNodeProfile node representing a function call
CallFrameinterfaceinterface CallFrameCall frame information
ProfileAnalysisinterfaceinterface ProfileAnalysisProfile analysis result
HotFunctioninterfaceinterface HotFunctionHot function information
SamplingResultinterfaceinterface SamplingResultSampling result
Sampleinterfaceinterface SampleIndividual sample
CPUProfilerclassclass CPUProfilerCPU Profiler class
createCPUProfilerfunctionfunction createCPUProfiler(config?: Partial<ProfilerConfig>): CPUProfilerCreate a CPU profiler with default configuration
MemoryProfilerConfiginterfaceinterface MemoryProfilerConfigMemory profiler configuration
Snapshotinterfaceinterface SnapshotHeap snapshot reference
Comparisoninterfaceinterface ComparisonSnapshot comparison result
LeakSuspectinterfaceinterface LeakSuspectSuspected memory leak
AllocationProfileinterfaceinterface AllocationProfileAllocation profile
Allocationinterfaceinterface AllocationSingle allocation event
GCMonitorinterfaceinterface GCMonitorGC monitor interface
GCEventinterfaceinterface GCEventGC event
GCMonitorStatsinterfaceinterface GCMonitorStatsGC monitoring statistics
RetentionTreeinterfaceinterface RetentionTreeRetention tree for object analysis
RetentionNodeinterfaceinterface RetentionNodeRetention tree node
MemoryProfilerclassclass MemoryProfilerMemory profiler class
createMemoryProfilerfunctionfunction createMemoryProfiler(Create a memory profiler with default configuration

Mengontrol sesi pengambilan sampel CPU V8 dan menghasilkan ekspor .cpuprofile yang kompatibel dengan Chrome DevTools.

Memeriksa statistik heap V8 dan memicu siklus garbage collection tertarget selama pengujian.

Menyimpan graf heap proses ke disk untuk retensi offline dan analisis kebocoran memori.

  • src/profiling/cpu-profiler.ts
  • src/profiling/memory-profiler.ts