I'm using the .NET Framework 4.7.2.
Stopwatch sw = new Stopwatch();
sw.Start();
JsonDocument jdoc = JsonDocument.Parse("{\"a\":123456789}");
JsonElement test = jdoc.RootElement.GetProperty("a");
sw.Stop();
Console.WriteLine(test + $" ({sw.ElapsedMilliseconds}ms)");
It prints out 123456789 (39ms)
. I'm getting an average of 40ms. What's going on? Why is this so much slower than JavaScript's JSON.parse?