title: Is it possible to speed this method up?
body: <p>I have a method that uses loops through <code>7,753+</code> objects and Gets the value of each property for each object. Each object has <code>14</code> properties.</p>
  
  <pre><code>private void InitializeData(IList objects, PropertyInfo[] props, List&lt;DPV&gt; dataPs, List&lt;Dictionary&lt;string, object&gt;&gt; tod)
  {
      foreach (var item in objects)
      {
          var kvp = new Dictionary&lt;string, object&gt;();
          foreach (var p in props)
          {
              var dataPs = dataPs.FirstOrDefault(x =&gt; x.Name == p.Name);
              object returnData;
              if (dataPoint != null)
              {
                  int maxLength = (dataP.MaxLength == null) ? 0 : (int) dataP.MaxLength;
                  returnData = p.GetValue(item, null);
                  if (!string.IsNullOrEmpty(dataP.FormatString) &amp;&amp; !string.IsNullOrEmpty(returnData.ToString()))
                  {
                      returnData = FormatDataForDisplay(returnData, dataP, maxLength, "", 8);
                  }
              }
              else
              {
                  returnData = p.GetValue(item, null);
              }
              kvp.Add(p.Name, returnData);
          }
          tod.Add(kvp);
      }
  }
  </code></pre>
  
  <p>I believe <code>GetValue</code> is what takes the majority of the time in this method, The method took around <code>900ms</code> to run, but <code>GetValue</code> which is called <code>800,000+</code> times takes around <code>750ms (total, not per-call)</code>.</p>
  
  <pre><code>public List&lt;Dictionary&lt;string, object&gt;&gt; GetColumnOptions&lt;T&gt;(List&lt;T&gt; list)
      {
  
          var tod= new List&lt;Dictionary&lt;string, object&gt;&gt;();
  
  
  
          var objects = (IList)list[0];
          Type objType = objects[0].GetType();
  
          var props = objType.GetProperties(BindingFlags.DeclaredOnly |
                                                           BindingFlags.Public |
                                                           BindingFlags.Instance);
  
  
          var dPs= GetDPs();
  
  
  
          //Initialize aaData
          //I don't believe this is correct
          InitializeData2&lt;T&gt;(new List&lt;T&gt; { (T) objects}, props, dPs, tod);
  
          return tod;
      }
  </code></pre>