Timing

This loads the package.
In[1]:=
Click for copyable input
Let us look at the overhead of calculation time caused by the object orientation. We first define some simple test methods and fields within a class hierarchy.
In[2]:=
Click for copyable input
Next, we create objects to access the class members and check the evaluation.
In[4]:=
Click for copyable input
Out[4]=
Out[5]=
In[6]:=
Click for copyable input
Out[6]=
In[7]:=
Click for copyable input
Out[7]=
We are now ready to test the access delay due to object or class access. All timings were obtained in Mathematica 6.0.1 running in Mac OS X on a MacBook Pro with 2.2 GHz. All measurements are not fully reproducible and give a rough estimate about calculation times. Up to a factor of two in calculation times was observed between two identical inputs.
A public field is accessed faster than other class members. There are a few thousand accesses each second.
In[8]:=
Click for copyable input
Out[8]=
Out[9]=
Out[10]=
The access to a public method is slower.
In[11]:=
Click for copyable input
Out[11]=
Out[12]=
Out[13]=
Due to privilege checks, protected and private class members are slower in access.
In[14]:=
Click for copyable input
Out[14]=
Out[15]=
Out[16]=