المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : a puzzle for timing method



C# Programming
08-24-2009, 01:00 PM
public interface IncDec
{
void Increment();
void Decrement();
}

public class MyIncDec : IncDec
{
private int x;
public MyIncDec(int x)
{
this.x = x;
}
public void Increment()
{
this.x++;
}
public void Decrement()
{
this.x--;
}
}

Part 1: Implement a class which can be used to measure how long each invocation of the Increment and Decrement method takes (in milliseconds) and prints out this information. The class should fit in more or less transparently with existing clients of the IncDec interface.
Part 2: Imagine you need to do something similar (timing of method calls) for many places in an application. What other ideas come to mind, e.g. could you propose other ideas for getting timing information more conveniently?

I got this question need to answer, it is simple, just something confused to me. hope anyone can help me.
btw, what "The class should fit in more or less transparently with existing clients of the IncDec interface.
" means?