> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/es/desarrollo/profiling.md).

# Perfilado

Active el perfilador de rendimiento de PowerShell Universal para diagnosticar paneles, API y trabajos lentos mediante Measure-PSUBlock y el panel de resultados del perfilador.

{% hint style="info" %}
El perfilado solo funciona para el entorno integrado.
{% endhint %}

PowerShell Universal proporciona un perfilador de rendimiento para depurar problemas en los que la plataforma puede mostrar respuestas lentas. Esto resulta útil principalmente al crear paneles.

## Activar el perfilado

El perfilado aumentará el uso de memoria, ya que los datos de perfilado se almacenan en memoria. Puede activar el perfilado configurando la propiedad `Profiling` de appsettings.json. Su valor predeterminado es `false`. Deberá reiniciar PowerShell Universal después de activar o desactivar el perfilado.

```json
"Profiling": true
```

## Acceder a los datos de perfilado

Puede acceder a los datos de perfilado navegando a `/profiler/results-index`. Deberá haber iniciado sesión como administrador antes de poder acceder a esta URL.

Verá una lista de solicitudes y sus tiempos.

Al hacer clic en la solicitud se mostrará un desglose de los tiempos.

## Perfilar un endpoint de API

Puede perfilar un endpoint de API mediante `Measure-PSUBlock`. La API se mostrará por URL en el índice de resultados.

Por ejemplo, supongamos una API llamada `/process`.

```powershell
New-PSUEndpoint -Url "/process" -Endpoint {
    Measure-PSUBlock -Name 'Api' -ScriptBlock {
        Get-Process | Select-Object name
    }
} -Authentication -Timeout 0 
```

El resultado de perfilar esta API se mostraría por URL.

Al ver el perfil de esta API se mostraría el bloque que hemos medido.

## Perfilar una aplicación

{% hint style="info" %}
`Measure-UDBlock` es un alias de `Measure-PSUBlock`
{% endhint %}

Puede usar el perfilador integrado con las aplicaciones. De forma predeterminada, se registran determinados tiempos de acciones internas. También puede usar el cmdlet `Measure-PSUBlock` para medir bloques específicos dentro de su panel.

Por ejemplo, esta aplicación usa `Measure-PSUBlock` para medir el rendimiento del cmdlet `Start-Sleep`. El resultado es que el bloque tardará un segundo en ejecutarse.

```powershell
New-UDApp -Title 'App' -Content {
    New-UDDynamic -Id 'MyElement' -Content {
        Measure-PSUBlock -Name 'WithinDashboard' -ScriptBlock {
            Start-Sleep 1
        }
    }
}
```

Al revisar las solicitudes en el perfilador, deberá buscar `UDComponent\ElementPost` y `UDComponent\Element`. Estas son solicitudes de elementos dentro de las aplicaciones.

A continuación se muestra el resultado de ejemplo de la aplicación anterior. Observe que la URL incluye el ID del elemento `MyElement`. También notará que el bloque `WithinDashboard` tarda aproximadamente 1 segundo.

No todos los tiempos se muestran de forma predeterminada. Puede hacer clic en `show trivial` para expandir todos los tiempos.

## Perfilar un trabajo

Puede perfilar trabajos usando `Measure-PSUBlock` dentro de su script.

Por ejemplo, supongamos que tenemos un script que llama a `Get-Service`.

```powershell
Measure-PSUBlock -ScriptBlock {
    Get-Service
} -Name 'Get-Service'
```

Al ejecutar un perfil en este script, el trabajo se mostrará como `JobProfiler/{id}`. El id coincidirá con el ID del trabajo mostrado en la consola de administración.

El perfil incluirá el bloque que se midió.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/es/desarrollo/profiling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
