title: Dictionary with tuple key slower than nested dictionary. Why?
body: <p>I've tested the speed of retrieving, updating and removing values in a dictionary using a (int, int, string) tuple as key versus the same thing with a nested Dictionary:  Dictionary>>.</p>
  
  <p>My tests show the tuple dictionary to be a lot slower (58% for retrieving, 69% for updating and 200% for removing). I did not expect that. The nested dictionary needs to do more lookups, so why is the tuple dictionary that much slower?</p>
  
  <p>My test code:</p>
  
  <pre><code>    public static object TupleDic_RemoveValue(object[] param)
      {
          var dic = param[0] as Dictionary&lt;(int did, int eid, string name), string&gt;;
          var keysToRetrieve = param[2] as List&lt;(int did, int eid, string name)&gt;;
  
          foreach (var key in keysToRetrieve)
          {
              dic.Remove(key);
          }
  
          return dic;
  
      }
  
  
      public static object NestedDic_RemoveValue(object[] param)
      {
          var dic = param[1] as Dictionary&lt;int, Dictionary&lt;int, Dictionary&lt;string, string&gt;&gt;&gt;;
          var keysToRetrieve = param[2] as List&lt;(int did, int eid, string name)&gt;;
  
  
          foreach (var key in keysToRetrieve)
          {
              if (dic.TryGetValue(key.did, out var elementMap) &amp;&amp; elementMap.TryGetValue(key.eid, out var propertyMap))
                  propertyMap.Remove(key.name);
          }
  
          return dic;
  
      }
  </code></pre>
  
  <p>Extra info on the test:
  The dictionary contains a total of 10 000 entries. The keys are incrementing: ([0-100],[0-100],"Property[0-100]").
  In a single test 100 keys are retrieved (for which 10% was not present in the dictionary), 100 values are updated (for which 10% are new) or 100 keys are removed (for which 10% were not in the dictionary to begin with). Retrieval, updating and removing were 3 separate tests. Each test was executed 1000 times. I compared both the mean and median execution time.</p>