Click here to Skip to main content
12,297,275 members (61,910 online)
Click here to Skip to main content
Articles » Database » Database » General » Downloads

Stats

65.8K views
128 downloads
86 bookmarked
Posted

Identifying NHibernate-Related Bottlenecks through Performance Monitoring

, 10 Jun 2007 CPOL
A distilled methodology for detecting and isolating NHibernate-related performance and scalability issues
using System;

namespace Sample.Tests
{
    public abstract class BaseCommandTemplate
    {
        #region Constructors
        public BaseCommandTemplate(ThreadContext c)
        {
            context = c;
        }
        #endregion

        #region Properties
        protected TimeSpan TimeProcessing
        {
            get
            {
                return end.Subtract(start);
            }
        }
        #endregion

        #region Methods
        public void Execute()
        {
            Start();
            string response = ProcessCommand();
            Stop();
            ProcessResults(response);
        }

        protected abstract string ProcessCommand();

        private void Start()
        {
            start = DateTime.Now;
        }

        private void Stop()
        {
            end = DateTime.Now;
        }
        private void ProcessResults(string response)
        {
            CommandResult result = new CommandResult(TimeProcessing);
            context.CommandResults.Add(result);
            Console.Write("command completed: ");
            Console.Write(result.TimeProcessing.TotalSeconds);
            Console.Write(" sec - ");
            Console.WriteLine(response);
        }
        #endregion

        #region Members
        private ThreadContext context;
        private DateTime start;
        private DateTime end;
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

Peter Weissbrod
Web Developer
United States United States
Independent contract developer for .NET data-oriented systems.

not much to say about myself but feel free to contact me for any inquiries and comments!

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 10 Jun 2007
Article Copyright 2007 by Peter Weissbrod
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid