> 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

{% 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 pueda mostrar respuestas lentas. Esto resulta útil principalmente al crear Dashboards.

## Habilitar el perfilado

El perfilado aumentará el uso de memoria, ya que los datos de perfilado se almacenan en memoria. Puede habilitar el perfilado configurando la propiedad `Profiling` de appsettings.json. Su valor predeterminado es `false`. Deberá reiniciar PowerShell Universal después de habilitar o deshabilitar 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 para poder acceder a esta URL.

Verá una lista de solicitudes y sus tiempos.

![Índice de resultados](/files/tA4MXw7XAVFGGyWH1kZu)

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

![Tiempos](/files/HsBIu0cdWgR6gjPA8Y8n)

## Perfilar un endpoint de API

Puede perfilar un endpoint de API mediante `Measure-PSUBlock`. La API aparecerá 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 del perfilado de esta API aparecería por URL.

![](/files/vV61S2U13Vrjd6nYj0kg)

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

![](/files/rEZFjDy0gyMOfW30rmSo)

## Perfilar una aplicación

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

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

Por ejemplo, esta aplicación utiliza `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 dentro del perfilador, deberá buscar `UDComponent\ElementPost` y `UDComponent\Element`. Estas son solicitudes de elementos dentro de las Apps.

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

![Tiempos del dashboard](/files/GZFB9b1h8bTNxyK5TdAd)

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

![Todos los tiempos](/files/jh7lLQsvpWIqYpEz974u)

## Perfilar un trabajo

Puede perfilar trabajos utilizando `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 aparecerá como `JobProfiler/{id}`. El id coincidirá con el ID del trabajo mostrado en la consola de administración.

![](/files/RgAr8ZNAcdOFQkcyPZxN)

El perfil incluirá el bloque que se midió.

![](/files/KDzz3lmXbftA7q2AOKwj)


---

# 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.
