Click here to Skip to main content
15,912,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
Can anyone help me how to get the execution time of public method using Aspect.Net? For example, i have 2 class Class1, Class2, im running them one after one and want to show execution time.
Thank's for all replies!
Posted

1 solution

You can use the StopWatch class.

http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx[^]


Edit, having no idea what the in's or out's of Aspect are, but have had a brief look at one of the presentations, then based on this extract:
C#
%aspect Politeness
public class Politeness
{
%modules
    public static SayHello ()
    {
        System.Console.WriteLine("Hello");
    }
    public static SayBye ()
    {
        System.Console.WriteLine("Bye");
    }
%rules
    %before %call *
    %action public static void SayHelloAction
    { Politeness.SayHello()}
    %after %call *
    %action public static void SayByeAction { Politeness.SayBye()}


You would need to apply some function to the before and after section of the rules. As this seems to be coursework, I suggest you refer to your notes/course books. Any more than this and i would be probably giving you the answer, which of course would be cheating. (And I'm not looking up any more on the inner workings of Aspect!)

:)
 
Share this answer
 
v4
Comments
Sergey Alexandrovich Kryukov 14-Nov-11 20:28pm    
OP commented:

Well, i have to do that using Aspect.Net (https://www.facultyresourcecenter.com/curriculum/PL/pfv.aspx?ID=8658&c1=pl-pl&c2=PL&Login=&wa=wsignin1.0[^]).
DaveAuld 15-Nov-11 2:31am    
Thanks, I updated my answer a bit, and it smells of homework to me so not going to far with it.....
Sergey Alexandrovich Kryukov 16-Apr-12 21:29pm    
OK, I would understand that.

You put some quotation marks which would not compile, so I fixed them for you.

Using StopWatch class is a right idea: to best of my knowledge, this is the most accurate way of timing. By the way, one can retrieve the accuracy value guaranteed by a particular system using StopWatch class.

I voted 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900