title: Why is typed JSON parsing in C# SO MUCH slower than node.js JSON.parse?
body: <p>I have one simple JSON object in a string and I'm comparing the ellapsed time of parsing (deserializing) the object between C# (.NET core) and Node.js</p>
  <p>Node.js test:</p>
  <pre><code>const { performance } = require('perf_hooks');
  
  const data = '{&quot;_id&quot;:&quot;5ff0fa604a1956d24e936b15&quot;,&quot;index&quot;:0,&quot;guid&quot;:&quot;de606748-9b6f-473c-bef4-efce5cd2914d&quot;,&quot;isActive&quot;:true,&quot;balance&quot;:&quot;$1,475.89&quot;,&quot;picture&quot;:&quot;http://placehold.it/32x32&quot;,&quot;age&quot;:33,&quot;eyeColor&quot;:&quot;green&quot;,&quot;name&quot;:&quot;Clara Mcmahon&quot;,&quot;gender&quot;:&quot;female&quot;,&quot;company&quot;:&quot;QUILM&quot;,&quot;email&quot;:&quot;claramcmahon@quilm.com&quot;,&quot;phone&quot;:&quot;+1 (871) 509-3806&quot;,&quot;address&quot;:&quot;391 Schroeders Avenue, Ironton, Hawaii, 1368&quot;,&quot;about&quot;:&quot;Commodo aliqua Lorem adipisicing esse in deserunt incididunt quis. Commodo sint amet quis adipisicing exercitation non Lorem aliquip tempor velit incididunt laboris. Ullamco in id anim commodo incididunt sint ad amet.\\r\\n&quot;,&quot;registered&quot;:&quot;2014-05-23T05:47:53 -02:00&quot;,&quot;latitude&quot;:78.629772,&quot;longitude&quot;:10.274508}';
  let t0 = performance.now()
  let parsed = JSON.parse(data); // measuring this part
  let t1 = performance.now()
  console.log(t1-t0);
  </code></pre>
  <p>C# test:</p>
  <pre><code>string data = &quot;{\&quot;_id\&quot;:\&quot;5ff0fa604a1956d24e936b15\&quot;,\&quot;index\&quot;:0,\&quot;guid\&quot;:\&quot;de606748-9b6f-473c-bef4-efce5cd2914d\&quot;,\&quot;isActive\&quot;:true,\&quot;balance\&quot;:\&quot;$1,475.89\&quot;,\&quot;picture\&quot;:\&quot;http://placehold.it/32x32\&quot;,\&quot;age\&quot;:33,\&quot;eyeColor\&quot;:\&quot;green\&quot;,\&quot;name\&quot;:\&quot;Clara Mcmahon\&quot;,\&quot;gender\&quot;:\&quot;female\&quot;,\&quot;company\&quot;:\&quot;QUILM\&quot;,\&quot;email\&quot;:\&quot;claramcmahon@quilm.com\&quot;,\&quot;phone\&quot;:\&quot;+1 (871) 509-3806\&quot;,\&quot;address\&quot;:\&quot;391 Schroeders Avenue, Ironton, Hawaii, 1368\&quot;,\&quot;about\&quot;:\&quot;Commodo aliqua Lorem adipisicing esse in deserunt incididunt quis. Commodo sint amet quis adipisicing exercitation non Lorem aliquip tempor velit incididunt laboris. Ullamco in id anim commodo incididunt sint ad amet.\\r\\n\&quot;,\&quot;registered\&quot;:\&quot;2014-05-23T05:47:53 -02:00\&quot;,\&quot;latitude\&quot;:78.629772,\&quot;longitude\&quot;:10.274508}&quot;;
  Stopwatch watch = new Stopwatch();
  watch.Start();
  Person person = JsonSerializer.Deserialize&lt;Person&gt;(data); // measuring this part
  watch.Stop();
  Console.WriteLine(watch.ElapsedMilliseconds);
  
  //...
  
  public class Person
  {
      public string _id { get; set; }
      public int index { get; set; }
      public string guid { get; set; }
      public bool isActive { get; set; }
      public string balance { get; set; }
      public string picture { get; set; }
      public int age { get; set; }
      public string eyeColor { get; set; }
      public string name { get; set; }
      public string gender { get; set; }
      public string company { get; set; }
      public string email { get; set; }
      public string phone { get; set; }
      public string address { get; set; }
      public string about { get; set; }
      public string registered { get; set; }
      public float latitude { get; set; }
      public float longtitude { get; set; }
  }
  </code></pre>
  <h2><strong>The results:</strong></h2>
  <p><strong>Node.js</strong> <em>(v14.15.3)</em> returns <code>0.0380ms</code> on average</p>
  <p><strong>C#</strong> <em>(.NET core, net5.0, Release)</em> returns <code>40ms</code> on average</p>
  <h2><strong>The question:</strong></h2>
  <p>Why is C#'s <strong>TYPED</strong> JSON parsing performing such badly against node.js's <strong>dynamic</strong> JSON parsing?</p>
  <p>Am I measuring this badly? Why is this happening?</p>
  <p><em>P.S.: I'm building an app that listens for websockets and parses one JSON object in each websocket (with span of a couple of seconds), so that's why I'm benchmarking only one JSON object.</em></p>