Polymorphism's effect on efficiency
807569Aug 23 2006 — edited Aug 23 2006I am trying to measure the effect of OO principles (encapsulation, inheritance, and polymorphism) on a program's efficiency. I am basically creating two separate applications that do the same thing but are architecturally different, executing them, then comparing running times.
For an example, I'm testing the efficiency of a class with getters and setters against the efficiency of a class which performs the same tasks, but whose members are public (and thus accessed via Foo.memberName instead of Foo.getMember()).
I'm currently having trouble creating a test case for polymorphism which can show that using polymorphism is more costly than not efficiency-wise. My problem is that with simple classes I can't seem to really see a performance hit. Does anyone know which polymorphic elements/structures/practices will have the greatest effect on efficiency? And, do you have any ideas as to how I can exploit them in a simple example?