Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8484865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:29:17+00:00 2026-06-10T20:29:17+00:00

I recently found this article: http://coderjournal.com/2010/10/timing-the-execution-time-of-your-mvc-actions/ Which shows a nice little attribute that you

  • 0

I recently found this article:
http://coderjournal.com/2010/10/timing-the-execution-time-of-your-mvc-actions/

Which shows a nice little attribute that you can add to your Controller classes, which creates a stopwatch and sticks an X-Runtime header into the result.

I’ve been trying to add something similar to my WCF Rest service, but have been unable to figure it out so far. Any suggestions on how I could go about implementing something similar on my webservice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:29:18+00:00Added an answer on June 10, 2026 at 8:29 pm

    This is a perfect place for aspects. Check out post sharp.

    You can then create an aspect kind of like:

    /// <summary>
    /// Adds execution timing and automatic logging to the tagged method
    /// </summary>
    [Serializable]
    public class MethodTimeAttribute : OnMethodBoundaryAspect
    {
        private String MethodName { get; set; }
        private DateTime StartTime { get; set; }
    
        /// <summary>
        /// Method executed at build time. Initializes the aspect instance. After the execution
        /// of <see cref="CompileTimeInitialize"/>, the aspect is serialized as a managed 
        /// resource inside the transformed assembly, and deserialized at runtime.
        /// </summary>
        /// <param name="method">Method to which the current aspect instance 
        /// has been applied.</param>
        /// <param name="aspectInfo">Unused.</param>
        public override void CompileTimeInitialize(MethodBase method, AspectInfo aspectInfo)
        {
            MethodName = method.DeclaringType.FullName  "."  method.Name;
        }
    
    
        public override void OnEntry(MethodExecutionArgs args)
        {
            StartTime = DateTime.Now;
        }
    
        public override void OnExit(MethodExecutionArgs args)
        {
            Log.Debug(this, "Method {0} took {1} to execute", MethodName, DateTime.Now - StartTime);
        }
    }
    

    And all you have to do is tag your methods like this:

    [MethodTime]
    private void RunFor(TimeSpan runTime){
        // do stuff 
    }
    

    Advanced post sharp features require a license but simple ones like method boundary aspects are free.

    While this doesn’t test any network boundaries for your wcf service it will test your service implementation time.

    If you really wanted to you could create some custom behaviors and inject that into your WCF chain to test timing, but the likelihood of bottlenecks at that phase is pretty unlikely. What’s more likely is you are sending a lot of data so things are slow, or things in your implementation are slow, all of which can be tested server side or client side independently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I've read this article: http://www.smashingmagazine.com/2009/09/25/svn-strikes-back-a-serious-vulnerability-found/ Developers of many popular sites like apache.org, php.net
I recently found the following article: http://www.tsqltutorials.com/with-common-table-expressions.php The article doesn't list which version of
EDIT 9-3-10: I found this blog entry recently that was very enlightening. http://optimizermagic.blogspot.com/2007/12/outerjoins-in-oracle.html There
Recently searching for a 'technical article' I stumbled upon this Microsoft page: http://academic.research.microsoft.com/ .
I recently found an article online that told me about this: RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2
I just recently found myself writing this line of code, which i did not
I recently read this article on GWT Lightweight Metrics and found it intriguing, but
I recently learned about Pratt parsers from this excellent article and found Pratt parsers
I am using cocos2d-iphone, latest non-beta version. Recently I found this: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:effects , and
I recently found this which is great as its the API but it doesn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.