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
andRenderTimeStatistics
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
andRenderTimeStatistics
as pages<a href="MethodCallStatistics">Method Call Statistics</a> <a href="RenderTimeStatistics">Render Time Statistics</a>
- 0.0.1.0:
- Excluded the body of
OnParametersSet()
andOnAfterRender(bool firstRender)
from render timing - Render timing now works with
OnParametersSetAsync()
andOnAfterRenderAsync(bool firstRender)
- Added
enum StatisticsOrder
to get statistics ordered by any property
- Excluded the body of
- 0.0.0.1:
- Initial release