views:

101

answers:

1

I would like to run profiling code against some services running in testing and production. My plan is to use PostSharp to implement a class that looks like

    public class TimerAttribute : OnMethodBoundaryAspect
    {
        //some data members
        //...

        public override void OnEntry(MethodExecutionEventArgs eventArgs)
        {
            //write method entry time to file
        }

        public override void OnExit(MethodExecutionEventArgs eventArgs)
        {
            //write method exit time to file
        }
    }

Before I go too far, are there any potential pitfalls I should be aware of? Will widespread use (i.e. just adding a line to assemblyinfo) of these methods cause serious (in terms of the validity of the timing data) performance issues?

+2  A: 

For performance instrumentation, you should be aware of the overhead of the aspect. This overhead was important in previous versions of PostSharp, but has been greatly improved in PostSharp 2.0.

Regarding your code, I see the danger is that writing to the file may be slow and thread unsafe. It really depends on your context and objectives, of course.

Performance counters may be a good alternative.

Gael Fraiteur