-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsfeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssemblyThis issue is related to and / or impacts Blazor WebAssemblyquestion
Description
I have created two simple loops in Javascript and Blazor WebAssembly. I was going to love Blazor and had expected web assembly to be faster because it was compiled and optimized, but it was far slower than Javascript. I used .NET 6 Blazor web assembly. Did I do something wrong or Blazor is not designed for this scenario at all?
Javascript: 3 seconds
Blazor: 95 seconds
Javascript:
function Foo()
{
let fruit = [];
for (var i = 0; i < 5000000; i++) {
fruit[i] = "zzzz" + i.toString() + "yyy" + i.toString() +
i.toString() + i.toString() + i.toString();
}
let counter = 0;
for (var j = 0; j < fruit.length; j++)
if (fruit[j].indexOf("111") > 0)
counter++;
console.log(counter);
}
Blazor Web assembly:
void Foo()
{
DateTime dateTime = DateTime.Now;
var items = new string[5000000];
for (var i=0; i<items.Length; i++)
items[i] = "some string some string 111" + i.ToString();
var counter = 0;
for (var i = 0; i < items.Length; i++)
if (items[i].IndexOf("111") > 0)
counter++;
}
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsfeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssemblyThis issue is related to and / or impacts Blazor WebAssemblyquestion