Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A number of the answers here suggest benchmarking, which is a step in the right direction, but only the first step in the journey.</p> <p>My team has done a great deal of profiling and benchmarking in this area. The short version is <em>yes</em>, there are situations in which interfaces impose a small but measurable performance cost. <em>However</em> the actual cost depends on a great many factors, including how many interfaces are supported, how many of those interfaces a given reference is cast to, what the pattern of accesses are, and so on. The CLR has a great many heuristics in place designed to speed up interface access in common cases. </p> <p>If you are benchmarking one of those common cases, but your actual program falls into a less common case, then your benchmarking is <em>actively harmful</em> because it is giving you data that is misleading.</p> <p>Far better to do realistic performance measurements on <em>real</em> code. Use a profiler, write the code both ways, and see whether either way is measurably, repeatably faster in a way that is visible and relevant to the user.</p> <p>As for your reference to throwing and catching: the performance cost of throwing and catching should be irrelevant. Exceptions are by definition <em>exceptional</em>, not <em>common</em>. Furthermore, exceptions usually indicate that something is going to halt shortly; it usually doesn't matter whether something halts as fast as possible. If you are in a situation where your performance is gated by exceptions then you have bigger problems to solve: <em>stop throwing so many exceptions</em>. An exception thrown should be extremely rare.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload