automatic logging and statistics (C# application) -


i trying think on best way enter statistic , kind of logging in program. 1. have article statistics implement in program ?
2. can create attribute have before method call on timer measure time took run ?for example

class {   [runtimer]   public void foo()   {      // stuff   } } 

edit
want have opportunity have possibility of controlling statistics during run time, not ob dev or qa time.

one option make higher-order function time target function , log results:

public static class timingextensions {     public static func<r> time<r>(this func<r> target, action<string> logger)     {         return delegate         {             system.diagnostics.stopwatch s = new system.diagnostics.stopwatch();              s.start();              r value = target();              s.stop();              logger("function '" + target.method.name + "' elapsed ms: " + s.elapsedmilliseconds);               return value;         };      } } 

but if need heavy performance testing there frameworks out there that, well.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -