Virtual method calls

Since some say that virtual method calls are evil, I ran some tests to check how much overhead they create in C#.

Unchecked result: They are about 5 times slower than nonvirtual calls. However, before you get overly excited: On my machine I could still make 5 Million virtual calls in 0.04 milliseconds.

I guess in most cases the time spent in virtual calls will still be insignificant.

Addendum, for those who shy away from indirections: There’s no measurable penalty for nonvirtual calls (compared to inline code)


Comments are closed.

Create a free website or blog at

Up ↑

%d bloggers like this: