title: Performance of dynamic_cast?
body: <p>Before reading the question:<br>
  This question is not about how useful it is to use <code>dynamic_cast</code>. Its just about its performance.</p>
  
  <p>I've recently developed a design where <code>dynamic_cast</code> is used a lot.<br>
  When discussing it with co-workers almost everyone says that <code>dynamic_cast</code> shouldn't be used because of its bad performance (these are co-workers which have different backgrounds and in some cases do not know each other. I'm working in a huge company)</p>
  
  <p>I decided to test the performance of this method instead of just believing them.  </p>
  
  <p>The following code was used:</p>
  
  <pre><code>ptime firstValue( microsec_clock::local_time() );
  
  ChildObject* castedObject = dynamic_cast&lt;ChildObject*&gt;(parentObject);
  
  ptime secondValue( microsec_clock::local_time() );
  time_duration diff = secondValue - firstValue;
  std::cout &lt;&lt; "Cast1 lasts:\t" &lt;&lt; diff.fractional_seconds() &lt;&lt; " microsec" &lt;&lt; std::endl;
  </code></pre>
  
  <p>The above code uses methods from <code>boost::date_time</code> on Linux to get usable values.<br>
  I've done 3 <code>dynamic_cast</code> in one execution, the code for measuring them is the same.</p>
  
  <p>The results of 1 execution were the following:<br>
      Cast1 lasts:  74 microsec<br>
      Cast2 lasts:    2 microsec<br>
      Cast3 lasts: 1 microsec  </p>
  
  <p>The first cast always took 74-111 microsec, the following casts in the same execution took 1-3 microsec.</p>
  
  <p>So finally my questions:<br>
  Is <code>dynamic_cast</code> really performing bad?<br>
  According to the testresults its not. Is my testcode correct?<br>
  Why do so much developers think that it is slow if it isn't?</p>