Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Webassembly / C# .NET - Poor Performance / Comparison with C# .NET

$
0
0

Problem

My team of developers is transitioning from C#/WPF to Blazor/Web-Assembly. We are building very big and complex ui-application. During our first prototyp we encounted a very large and for us even crazy and unexplainable performance issue with blazor C#/.NET. It seems like complex C#/NET Code in Loops is running very slow. We found similar issues in several different technical use-cases.

Test-Case

To be able to post this here, we excracted this isse in to the following very simple test-case:

List<MyClass> classList = new List<MyClass>();int counter = 10000;for (int i = 0; i < counter; i++){    var c = new MyClass();    c.Prop1 = "test";    c.Prop2 = 1;    classList.Add(c);}public class MyClass{    public string? Prop1 { get; set; }    public int? Prop2 { get; set; }}

Performance

We then compared the code-snippet above, running on Blazor/Webassembly in Chrome vs. running on C#/WPF.

Which leads uns to the following meassured Performance (times in ms, same hardware, .NET 8, meassured times are avg. of 10 tries, wpf fully built is even faster and there for not recorded):

counterBlazor/DebugBlazor/PublishWPF/Debug
10.0001.300 ms180 ms10 ms
100.00012.000 ms1.400 ms250 ms

Conclusion

We expected an somewhat closer to native performance.On the other hand is, everything UI and Blazor/Razor-Component related seems to be very fast.

Debugging Performance

We were most suprised about the crazy difference in performance in the "Debugger" using the same Visual-Studio 2022. We know that debuggin creates an overhead, but on Blazor-Debugger the code takes about 50!! times longer to run than on C#/WPF-Debugger.

Life/Published Performance

Then we compared the performance for published Blazor/Webassembly vs C#/WPF.And still the code takes about 5!! times longer to run on Blazor than on C#/WPF in Debugger.

Unanswered Questions

Is there anything we can to a) speed up performance during debugging and b) to get somewhat better (closer to nativ) performance for C#-Code-Execution?Has anyone meassured/expierenced something similar and maybe even found some improvements for this?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>