Hi
Is this class and code snippet not good enough to see the differences
between having a collection of a value type compared with having a
collection of references to a reference type (containing that same
value type)? Using a wrapper around Win32's QueryPerformanceCounter
and some tracing I see very little difference.
class WrappedRectangleF
{
public WrappedRectangleF(RectangleF theRectangleF)
{
_theRectangleF = theRectangleF;
}
public override String ToString()
{
return _theRectangleF.ToString();
}
RectangleF _theRectangleF;
}
FOR BOXING/UNBOXING
int iterations = 100000;
ArrayList container = new ArrayList(iterations);
for (int i = 0; i < iterations; ++i)
{
container.Add(new RectangleF(5, 5, 5, 5));
}
for (int i = 0; i < iterations; ++i)
{
container[i].ToString();
}
COMPARE WITH THE FOLLOWING ...
int iterations = 100000;
ArrayList container = new ArrayList(iterations);
for (int i = 0; i < iterations; ++i)
{
container.Add(new WrappedRectangleF(new RectangleF(5, 5, 5, 5)));
}
for (int i = 0; i < iterations; ++i)
{
container[i].ToString();
}
Any ideas?
Emma Middlebrook
em**************@fastmail.fm