Click here to Skip to main content
15,881,380 members
Articles / DevOps / Load Testing

Measuring and Monitoring WCF Web Service Performance

Rate me:
Please Sign up or sign in to vote.
5.00/5 (17 votes)
4 Oct 2012GPL310 min read 55.2K   2.2K   47  
Using ServiceMon to obtain performance statistics for web services
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Kaleida.ServiceMonitor.Model;

namespace Kaleida.ServiceMonitor.UI.NotificationPanels
{
    public partial class TenFootNotificationPanel : UserControl, INotificationPanel
    {
        private IEnumerable<ScriptSourceMenuItem> scriptMenuItems = Enumerable.Empty<ScriptSourceMenuItem>();
        private Monitor monitor;

        public TenFootNotificationPanel()
        {
            InitializeComponent();
        }

        public void Initialise(Monitor monitorApplication)
        {
            monitor = monitorApplication;
        }

        public string PanelName
        {
            get { return "10' Summary"; }
        }

        public void RefreshContent()
        {
            var presentation = monitor.State.DefaultPresentation;

            BackColor = presentation.GetNotificationColour();
            lbl10FootSymbol.Text = presentation.GetNotificationWord();
            lbl10FootDetail.Text = presentation.GetStateDetail();

            lblScriptName.Text = monitor.Workspace.CurrentScript.Name;
        }

        public Control GetPanelControl()
        {
            return this;
        }

        private void TenFootNotificationPanel_Resize(object sender, EventArgs e)
        {
            var isMini = Width < 400 || Height < 200;            
            
            lblScriptName.Font = new Font(FontFamily.GenericSansSerif, isMini ? 18 : 26);
            lbl10FootSymbol.Visible = !isMini;
            lbl10FootDetail.Height = isMini ? 48 : 56;
            lbl10FootDetail.Font = isMini ? new Font("Segoe UI", 7.5f) : new Font("Courier New", 8.25f);
        }

        private void OnSelectScriptClicked(object sender, EventArgs e)
        {
            var menuItem = (ScriptSourceMenuItem)sender;

            monitor.Workspace.CurrentScript = menuItem.Script;
        }

        private void contextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            miStartMonitoring.Enabled = monitor.State.CanBeginMonitoring;
            miStopMonitoring.Enabled = monitor.State.IsMonitoring;
            miAcknowledgeErrors.Enabled = monitor.State.HasOperationFailures;

            var allScripts = monitor.Workspace.LoadedScripts;
            scriptMenuItems = allScripts.Select(i => new ScriptSourceMenuItem(i, OnSelectScriptClicked));
            miSelectScript.DropDownItems.Clear();
            miSelectScript.DropDownItems.AddRange(scriptMenuItems.Cast<ToolStripItem>().ToArray());
            miSelectScript.Enabled = allScripts.Any();
        }

        private void miStartMonitoring_Click(object sender, EventArgs e)
        {
            monitor.State.StartMonitoring();
        }

        private void miStopMonitoring_Click(object sender, EventArgs e)
        {
            monitor.State.StopMonitoring();
        }

        private void miAcknowledgeError_Click(object sender, EventArgs e)
        {
            monitor.AcknowledgeErrors();
        }
    }
}

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 GNU General Public License (GPLv3)


Written By
Architect BlackJet Software Ltd
United Kingdom United Kingdom
Stuart Wheelwright is the Principal Architect and Software Developer at BlackJet Software Ltd.

He has over 16 years commercial experience producing robust, maintainable, web-based solutions and bespoke systems for Microsoft platforms.

His latest project is Shopping UK, an elegantly simple shopping list for iPhone.

Comments and Discussions