You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react/Profiler.md
+31-25Lines changed: 31 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,17 @@
1
1
---
2
2
title: <Profiler>
3
+
translationStatus: ai-draft
3
4
---
4
5
6
+
<Note>
7
+
8
+
Questa pagina è stata tradotta automaticamente e supervisionata da un maintainer. Un'ulteriore revisione da parte della community sarebbe comunque utile. [Migliora questa traduzione](https://github.com/reactjs/it.react.dev/edit/main/src/content/reference/react/Profiler.md).
9
+
10
+
</Note>
11
+
5
12
<Intro>
6
13
7
-
`<Profiler>`lets you measure rendering performance of a React tree programmatically.
14
+
`<Profiler>`ti permette di misurare programmaticamente le prestazioni di renderizzazione di un albero React.
8
15
9
16
```js
10
17
<Profiler id="App" onRender={onRender}>
@@ -22,7 +29,7 @@ title: <Profiler>
22
29
23
30
### `<Profiler>` {/*profiler*/}
24
31
25
-
Wrap a component tree in a`<Profiler>`to measure its rendering performance.
32
+
Avvolgi un albero di componenti in un`<Profiler>`per misurare le prestazioni di renderizzazione.
26
33
27
34
```js
28
35
<Profiler id="App" onRender={onRender}>
@@ -32,41 +39,41 @@ Wrap a component tree in a `<Profiler>` to measure its rendering performance.
32
39
33
40
#### Props {/*props*/}
34
41
35
-
*`id`: A string identifying the part of the UI you are measuring.
36
-
*`onRender`: An[`onRender` callback](#onrender-callback)that React calls every time components within the profiled tree update. It receives information about what was rendered and how much time it took.
42
+
*`id`: Una stringa che identifica la parte dell'interfaccia utente che stai misurando.
43
+
*`onRender`: Una[`callback onRender`](#onrender-callback)che React chiama ogni volta che i componenti nell'albero profilato si aggiornano. Riceve informazioni su cosa è stato renderizzato e quanto tempo ha richiesto.
37
44
38
45
#### Caveats {/*caveats*/}
39
46
40
-
*Profiling adds some additional overhead, so**it is disabled in the production build by default.**To opt into production profiling, you need to enable a [special production build with profiling enabled.](/reference/dev-tools/react-performance-tracks#using-profiling-builds)
47
+
*Il profiling aggiunge un overhead aggiuntivo, quindi**è disabilitato di default nella build di produzione.**Per attivare il profiling in produzione, devi abilitare una [build di produzione speciale con il profiling attivato.](/reference/dev-tools/react-performance-tracks#using-profiling-builds)
41
48
42
49
---
43
50
44
51
### `onRender` callback {/*onrender-callback*/}
45
52
46
-
React will call your `onRender`callback with information about what was rendered.
53
+
React chiamerà la tua callback `onRender`con informazioni su cosa è stato renderizzato.
//Aggrega o registra i tempi di renderizzazione...
51
58
}
52
59
```
53
60
54
61
#### Parameters {/*onrender-parameters*/}
55
62
56
-
*`id`: The string `id`prop of the `<Profiler>`tree that has just committed. This lets you identify which part of the tree was committed if you are using multiple profilers.
57
-
*`phase`: `"mount"`, `"update"`or`"nested-update"`. This lets you know whether the tree has just been mounted for the first time or re-rendered due to a change in props, state, or Hooks.
58
-
*`actualDuration`: The number of milliseconds spent rendering the `<Profiler>`and its descendants for the current update. This indicates how well the subtree makes use of memoization (e.g. [`memo`](/reference/react/memo)and[`useMemo`](/reference/react/useMemo)). Ideally this value should decrease significantly after the initial mount as many of the descendants will only need to re-render if their specific props change.
59
-
*`baseDuration`: The number of milliseconds estimating how much time it would take to re-render the entire `<Profiler>`subtree without any optimizations. It is calculated by summing up the most recent render durations of each component in the tree. This value estimates a worst-case cost of rendering (e.g. the initial mount or a tree with no memoization). Compare`actualDuration`against it to see if memoization is working.
60
-
*`startTime`: A numeric timestamp for when React began rendering the current update.
61
-
*`commitTime`: A numeric timestamp for when React committed the current update. This value is shared between all profilers in a commit, enabling them to be grouped if desirable.
63
+
*`id`: La stringa della prop `id`dell'albero `<Profiler>`appena sottoposto a commit. Ti permette di identificare quale parte dell'albero ha effettuato il commit se usi più profiler.
64
+
*`phase`: `"mount"`, `"update"`o`"nested-update"`. Ti indica se l'albero è stato montato per la prima volta o renderizzato di nuovo a causa di un cambiamento di props, state o Hooks.
65
+
*`actualDuration`: Il numero di millisecondi impiegati per renderizzare il `<Profiler>`e i suoi discendenti per l'aggiornamento corrente. Indica quanto bene il sottoalbero sfrutta la memorizzazione (ad esempio [`memo`](/reference/react/memo)e[`useMemo`](/reference/react/useMemo)). Idealmente questo valore dovrebbe diminuire significativamente dopo il montaggio iniziale, poiché molti discendenti dovranno renderizzare di nuovo solo se cambiano le loro props specifiche.
66
+
*`baseDuration`: Il numero di millisecondi stimati per renderizzare di nuovo l'intero sottoalbero `<Profiler>`senza ottimizzazioni. Viene calcolato sommando le durate di renderizzazione più recenti di ogni componente nell'albero. Questo valore stima il costo nel caso peggiore di renderizzazione (ad esempio il montaggio iniziale o un albero senza memorizzazione). Confronta`actualDuration`con questo valore per verificare se la memorizzazione funziona.
67
+
*`startTime`: Un timestamp numerico relativo al momento in cui React ha iniziato a renderizzare l'aggiornamento corrente.
68
+
*`commitTime`: Un timestamp numerico relativo al momento in cui React ha effettuato il commit dell'aggiornamento corrente. Questo valore è condiviso tra tutti i profiler in un commit, permettendone il raggruppamento se necessario.
### Misurare programmaticamente le prestazioni di renderizzazione {/*measuring-rendering-performance-programmatically*/}
68
75
69
-
Wrap the `<Profiler>`component around a React tree to measure its rendering performance.
76
+
Avvolgi il componente `<Profiler>`attorno a un albero React per misurare le prestazioni di renderizzazione.
70
77
71
78
```js {2,4}
72
79
<App>
@@ -77,28 +84,28 @@ Wrap the `<Profiler>` component around a React tree to measure its rendering per
77
84
</App>
78
85
```
79
86
80
-
It requires two props: an`id` (string) and an `onRender`callback (function) which React calls any time a component within the tree "commits" an update.
87
+
Richiede due props: un`id` (stringa) e una callback `onRender`(funzione) che React chiama ogni volta che un componente nell'albero effettua il commit di un aggiornamento.
81
88
82
89
<Pitfall>
83
90
84
-
Profiling adds some additional overhead, so**it is disabled in the production build by default.**To opt into production profiling, you need to enable a [special production build with profiling enabled.](/reference/dev-tools/react-performance-tracks#using-profiling-builds)
91
+
Il profiling aggiunge un overhead aggiuntivo, quindi**è disabilitato di default nella build di produzione.**Per attivare il profiling in produzione, devi abilitare una [build di produzione speciale con il profiling attivato.](/reference/dev-tools/react-performance-tracks#using-profiling-builds)
85
92
86
93
</Pitfall>
87
94
88
95
<Note>
89
96
90
-
`<Profiler>`lets you gather measurements programmatically. If you're looking for an interactive profiler, try the Profiler tab in [React Developer Tools](/learn/react-developer-tools). It exposes similar functionality as a browser extension.
97
+
`<Profiler>`ti permette di raccogliere misurazioni programmaticamente. Se cerchi un profiler interattivo, prova la scheda _Profiler_ in [React Developer Tools](/learn/react-developer-tools). Espone funzionalità simili come estensione del browser.
91
98
92
-
Components wrapped in `<Profiler>`will also be marked in the [Component tracks](/reference/dev-tools/react-performance-tracks#components)of React Performance tracks even in profiling builds.
93
-
In development builds, all components are marked in the Components track regardless of whether they're wrapped in `<Profiler>`.
99
+
I componenti avvolti in `<Profiler>`saranno anche contrassegnati nella [traccia Components](/reference/dev-tools/react-performance-tracks#components)di React Performance tracks anche nelle build con profiling.
100
+
Nelle build di development, tutti i componenti sono contrassegnati nella traccia Components indipendentemente dal fatto che siano avvolti in `<Profiler>`.
94
101
95
102
</Note>
96
103
97
104
---
98
105
99
-
### Measuring different parts of the application {/*measuring-different-parts-of-the-application*/}
106
+
### Misurare diverse parti dell'applicazione {/*measuring-different-parts-of-the-application*/}
100
107
101
-
You can use multiple`<Profiler>`components to measure different parts of your application:
108
+
Puoi usare più componenti`<Profiler>`per misurare diverse parti della tua applicazione:
102
109
103
110
```js {5,7}
104
111
<App>
@@ -111,7 +118,7 @@ You can use multiple `<Profiler>` components to measure different parts of your
111
118
</App>
112
119
```
113
120
114
-
You can also nest`<Profiler>` components:
121
+
Puoi anche annidare componenti`<Profiler>`:
115
122
116
123
```js {5,7,9,12}
117
124
<App>
@@ -129,7 +136,6 @@ You can also nest `<Profiler>` components:
129
136
</App>
130
137
```
131
138
132
-
Although`<Profiler>`is a lightweight component, it should be used only when necessary. Each use adds some CPU and memory overhead to an application.
139
+
Sebbene`<Profiler>`sia un componente leggero, dovrebbe essere usato solo quando necessario. Ogni utilizzo aggiunge un overhead di CPU e memoria all'applicazione.
0 commit comments