couldn't resist and tested it and it looks like almost no overhead.
Participants are:
Interface IFoo defining a method
class Foo: IFoo implements IFoo
class Bar implements the same method as Foo, but no interface involved
so i defined
Foo realfoo = new Foo();
IFoo ifoo = new Foo();
Bar bar = new Bar();
and called the method, which does 20 string concatenations, 10,000,000 times on each variable.
realfoo: 723 Milliseconds
ifoo: 732 Milliseconds
bar: 728 Milliseconds
If the method does nothing, the actual calls stand out a bit more.
realfoo: 48 Milliseconds
ifoo: 62 Milliseconds
bar: 49 Milliseconds
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…