Poor Man's Blazor Wasm Profiler
It uses AspectInjector
to time the execution of every method in your Blazor WASM project.
It also measures the render time of every Blazor Component that defines these methods:
protected override void OnParametersSet()
// or
protected override async Task OnParametersSetAsync()
// and
protected override void OnAfterRender(bool firstRender)
// or
protected override async Task OnAfterRenderAsync(bool firstRender)
Include NuGet package from https://www.nuget.org/packages/BlazorWasmProfiler
<ItemGroup>
<PackageReference Include="BlazorWasmProfiler" Version="0.0.1.0" />
</ItemGroup>
Add the attribute somewhere in your code
[assembly: BlazorTimer]
[assembly: MethodTimer]
[assembly: RenderTimer]
Access statistics
var methodStatistics = BlazorTimerAttribute.GetMethodStatistics();
var renderStatistics = BlazorTimerAttribute.GetRenderStatistics();
var methodStatistics = ExecutionStatistics.GetMethodStatistics();
var renderStatistics = ExecutionStatistics.GetRenderStatistics();
(optional) Use MethodCallStatistics
and RenderTimeStatistics
as components
<BlazorWasmProfiler.MethodCallStatistics />
<BlazorWasmProfiler.RenderTimeStatistics />
(optional) Change
<Router AppAssembly="@typeof(App).Assembly">
to
<Router
AppAssembly="@typeof(App).Assembly"
AdditionalAssemblies="new[] { typeof(BlazorWasmProfiler.BlazorTimerAttribute).Assembly }">
and use MethodCallStatistics
and RenderTimeStatistics
as pages
<a href="https://github.com/Jinjinov/BlazorWasmProfiler/blob/main/MethodCallStatistics">Method Call Statistics</a>
<a href="https://github.com/Jinjinov/BlazorWasmProfiler/blob/main/RenderTimeStatistics">Render Time Statistics</a>
OnParametersSet()
and OnAfterRender(bool firstRender)
from render timingOnParametersSetAsync()
and OnAfterRenderAsync(bool firstRender)
enum StatisticsOrder
to get statistics ordered by any property