<Profiler>
<Profiler> γδ½Ώγγγ¨γ§γReact γγͺγΌοΏ½?γ¬γ³γγͺγ³γ°γγγ©γΌγγ³γΉγγγγ°γ©γ γ§ζΈ¬οΏ½?οΏ½γγγγ¨γγ§γγΎγγ
<Profiler id="App" onRender={onRender}>
<App />
</Profiler>γͺγγ‘γ¬γ³γΉ
<Profiler>
γ³γ³γγΌγγ³γγγͺγΌγ <Profiler> γ§γ©γγγγγγ¨γ§γγ¬γ³γγΌοΏ½?γγγ©γΌγγ³γΉγζΈ¬οΏ½?οΏ½γγγγ¨γγ§γγΎγγ
<Profiler id="App" onRender={onRender}>
<App />
</Profiler>props
id: UI οΏ½?γ©οΏ½?ι¨εγζΈ¬οΏ½?�対豑γ¨γγ¦γγοΏ½?γθε₯γγγγοΏ½?ζεεγ§γγonRender: γγγγ‘γ€γͺγ³γ°ε―Ύθ±‘οΏ½?γγͺγΌε οΏ½?γ³γ³γγΌγγ³γγζ΄ζ°γγγγγ³γ« React γεΌγ³εΊγonRenderγ³γΌγ«γγγ―γδ½γγ¬γ³γγΌγγγγγγ«γ©γγ γοΏ½?ζιγγγγ£γγγ«γ€γγ¦οΏ½?ζ ε ±γεγεγγΎγγ
注ζηΉ
- γγγγ‘γ€γͺγ³γ°γ«γ―θΏ½ε οΏ½?γͺγΌγγΌγγγγηΊηγγγγγγγγ©γ«γγ§γ―ζ¬ηͺη¨γγ«γγ§γ―η‘εΉγ«γͺγ£γ¦γγΎγγζ¬ηͺη°ε’γ§γγγγ‘γ€γͺγ³γ°γθ‘γγγγ«γ―γγγγγ‘γ€γͺγ³γ°γζεΉγ«γγγͺηΉε₯γͺζ¬ηͺη¨γγ«γγζη€Ίηγ«η¨γγεΏ θ¦γγγγΎγγ
onRender γ³γΌγ«γγγ―
React γ― onRender γ³γΌγ«γγγ―γεΌγ³εΊγγ¦γδ½γγ¬γ³γγΌγγγγγ«γ€γγ¦οΏ½?ζ
ε ±γδΌγγΎγγ
function onRender(id, phase, actualDuration, baseDuration, startTime, commitTime) {
// Aggregate or log render timings...
}εΌζ°
id: γγ£γδ»γ³γγγγγγγγͺγΌγ«ε―ΎεΏγγ<Profiler>οΏ½?idγγγγγ£γθ€ζ°οΏ½?γγγγ‘γ€γ©γδ½Ώη¨γγ¦γγε ΄εγ«γγ©οΏ½?γγͺγΌγγ³γγγγγγγγγγγ«γγθε₯γ§γγΎγγphase:"mount"γ"update"γγΎγγ―"nested-update"γγγγ«γγγγγͺγΌγεγγ¦γγ¦γ³γγγγοΏ½?γγpropsγstateγγΎγγ―γγγ―οΏ½?ε€ζ΄γ«γγεγ¬γ³γγΌγγγοΏ½?γγη₯γγγ¨γγ§γγΎγγactualDuration: ηΎε¨οΏ½?ζ΄ζ°οΏ½?γγγ«<Profiler>γ¨γοΏ½?εθ¦η΄ γγ¬γ³γγΌγ«θ²»γγγγγͺη§ζ°γγγγ―γγ΅γγγͺγΌγγ‘γ’εοΌδΎοΌmemoγ¨useMemoοΌγγ©γγ γγγΎγε©η¨γ§γγ¦γγγγη€ΊγγοΏ½?γ§γγηζ³ηγ«γ―γεθ¦η΄ οΏ½?ε€γγθͺθΊ«οΏ½? props γε€ζ΄γγγε ΄εγ«οΏ½?γΏεγ¬γ³γγΌγγγγγγ«γͺγγγ¨γ§γγοΏ½?ε€γ―εεγγ¦γ³γεΎγ«ε€§εΉ γ«ζΈε°γγ¦γγγ―γγ§γγbaseDuration: γγζι©εγͺγγ§<Profiler>γ΅γγγͺγΌε ¨δ½γεγ¬γ³γγΌγγε ΄εγ«γγγζιγγγͺη§γ§ζ¨οΏ½?οΏ½γγζ°ε€γγγͺγΌε οΏ½?εγ³γ³γγΌγγ³γοΏ½?ζεΎοΏ½?γ¬γ³γγΌγ«γγγ£γζιγεθ¨γγγγ¨γ§θ¨οΏ½?οΏ½γγγΎγγγοΏ½?ε€γ―γζζͺοΏ½?γγͺγΌοΏ½?γ¬γ³γγΌγ³γΉγοΌδΎοΌεεγγ¦γ³γγγ‘γ’εγγͺγε ΄εοΌγζ¨οΏ½?οΏ½γγΎγγγ‘γ’εγζ©θ½γγ¦γγγγ©γγγη’Ίθͺγγγ«γ―γγοΏ½?ε€γactualDurationγ¨ζ―θΌγγΎγγstartTime: React γηΎε¨οΏ½?ζ΄ζ°οΏ½?γ¬γ³γγΌγιε§γγζε»οΏ½?γΏγ€γ γΉγΏγ³γγcommitTime: React γηΎε¨οΏ½?ζ΄ζ°γγ³γγγγγζε»οΏ½?γΏγ€γ γΉγΏγ³γγγοΏ½?ε€γ―εδΈγ³γγγε οΏ½?γγΉγ¦οΏ½?γγγγ‘γ€γ©ιγ§ε ±ζγγγγγγεΏ θ¦γ«εΏγγ¦γ°γ«γΌγεγγγγγ«ε©η¨γ§γγΎγγ
δ½Ώη¨ζ³
γ¬γ³γγΌοΏ½?γγγ©γΌγγ³γΉγγγγ°γ©γ γ§ζΈ¬οΏ½?οΏ½γγ
React γγͺγΌγ <Profiler> γ³γ³γγΌγγ³γγ§ε²γγγ¨γ§γγοΏ½?γ¬γ³γγΌοΏ½?γγγ©γΌγγ³γΉγζΈ¬οΏ½?οΏ½γγΎγγ
<App>
<Profiler id="Sidebar" onRender={onRender}>
<Sidebar />
</Profiler>
<PageContent />
</App>idοΌζεεοΌγ¨ onRender γ³γΌγ«γγγ―οΌι’ζ°οΌοΏ½? 2 γ€οΏ½? props γεΏ
θ¦γ§γγReact γ―γγͺγΌε
οΏ½?γ³γ³γγΌγγ³γγζ΄ζ°γγγ³γγγγγγγγ³γ«γγγεΌγ³εΊγγΎγγ
γ’γγͺγ±γΌγ·γ§γ³οΏ½?θ€ζ°ι¨δ½γζΈ¬οΏ½?οΏ½γγ
γ’γγͺγ±γΌγ·γ§γ³οΏ½?θ€ζ°οΏ½?ι¨δ½γζΈ¬οΏ½?οΏ½γγγγγ«γθ€ζ°οΏ½? <Profiler> γ³γ³γγΌγγ³γγδ½Ώη¨γγγγ¨γγ§γγΎγγ
<App>
<Profiler id="Sidebar" onRender={onRender}>
<Sidebar />
</Profiler>
<Profiler id="Content" onRender={onRender}>
<Content />
</Profiler>
</App>γΎγγ<Profiler> γ³γ³γγΌγγ³γγγγΉγγγγγ¨γγ§γγΎγγ
<App>
<Profiler id="Sidebar" onRender={onRender}>
<Sidebar />
</Profiler>
<Profiler id="Content" onRender={onRender}>
<Content>
<Profiler id="Editor" onRender={onRender}>
<Editor />
</Profiler>
<Preview />
</Content>
</Profiler>
</App><Profiler> γ―θ»½ιγͺγ³γ³γγΌγγ³γγ§γγγεΏ
θ¦γͺε ΄εγ«οΏ½?γΏδ½Ώη¨γγγΉγγ§γγδ½Ώη¨γγγγ³γ«γ’γγͺγ±γΌγ·γ§γ³γ«δΈοΏ½?οΏ½οΏ½? CPU γ¨γ‘γ’γͺοΏ½?γͺγΌγγΌγγγγηγγΎγγ