Click here to Skip to main content
15,893,486 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.4K   2.2K   47  
Using ServiceMon to obtain performance statistics for web services
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using CodePlex.WebServices.Client;

namespace Kaleida.ServiceMonitor.CodePlexUploader
{
    class Program
    {
        private const int ExitCodeSuccess = 0;
        private const int ExitCodeError = 1;

        private const string ProjectName = "ServiceMon";

        static void Main(string[] args)
        {
            if(args.Count() != 5)
            {
                Console.WriteLine("Must provide the following arguments on the command line: CodePlexUsername, CodePlexPassword, ZipFilePath, MsiFilePath, ReleaseType (e.g. Alpha,Beta,Stable)");
                Environment.Exit(ExitCodeError);
            }

            string username = args[0];
            string password = args[1];
            string zipFilePath = args[2];
            string msiFilePath = args[3];
            string releaseType = args[4];

            try
            {
                // Set the thread culture to en-US to get around a localisation issue in the CodePlex ReleaseService 
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");

                var releaseService = new ReleaseService();
                releaseService.Credentials = new NetworkCredential(username, password);

                string releaseName = GetReleaseName();
                var releaseStatus = (ReleaseStatus) Enum.Parse(typeof (ReleaseStatus), releaseType);
                int releaseId = releaseService.CreateARelease(ProjectName, releaseName, "Auto-uploaded from build server", DateTime.Now, releaseStatus, true, false);
                Console.WriteLine("Successfully created release '{0}'. Release ID={1}", releaseName, releaseId);

                var releaseFiles = new List<ReleaseFile>
                                       {
                                           new ReleaseFile(zipFilePath, "application/zip", ReleaseFileType.RuntimeBinary) {FileData = File.ReadAllBytes(zipFilePath)},
                                           new ReleaseFile(msiFilePath, "application/x-msi", ReleaseFileType.RuntimeBinary) {FileData = File.ReadAllBytes(msiFilePath)},
                                       };
                releaseService.UploadReleaseFiles(ProjectName, releaseName, releaseFiles, Path.GetFileName(msiFilePath));

                Console.WriteLine("Successfully uploaded release files");
                Environment.Exit(ExitCodeSuccess);
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error creating new release: " + exception);
                Environment.Exit(ExitCodeError);
            }
        }

        private static string GetReleaseName()
        {
            var assembly = typeof(Program).Assembly;
            var version = assembly.GetName().Version;
            return "ServiceMon Release " + version;
        }
    }
}

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