1

I have some relatively simple transactions that run against my application like "start user session" which typically takes a couple seconds when running a VS project through SilkPerformer. When I try to execute the same transaction using the VS 2015 performance testing tools (locally on the controller) the response times are roughly twelve seconds longer, repeatedly.

I have a transaction logger that captures the response times of each transaction so I can see them individually during the execution in VS and I'm wondering if I'm missing a setting somewhere or there is a configuration change I can make to the project because it almost seems as if the project is pacing the execution of the transactions. I get the same behavior whether running on an agent or the controller directly so it doesn't appear to be network related.

This is a sample of the code that's executing:

    public interface ITestTransactionTimer : IDisposable { }

    public class TestTransactionTimer : ITestTransactionTimer
    {
        public TestContext TestContext { get; private set; }
        public string TransactionName { get; private set; }

        public TestTransactionTimer(TestContext testContext, string transactionName)
        {
            this.TestContext = testContext;
            this.TransactionName = transactionName;

            this.TestContext.BeginTimer(this.TransactionName);
        }

        public void Dispose()
        {
            this.TestContext.EndTimer(this.TransactionName);
        }
    }

    public class NoOpTestTransactionTimer : ITestTransactionTimer
    {
        public void Dispose() { }
    }
    protected ITestTransactionTimer LogTransaction(string transactionName)
    {
        if ((null == this.TestContext) || !this.TestContext.Properties.Contains("$LoadTestUserContext"))
        {
            return new NoOpTestTransactionTimer();
        }
        return new TestTransactionTimer(this.TestContext, transactionName);
    }


    private TestContext testContextInstance;
    public TestContext TestContext
    {
        get { return testContextInstance; }
        set { testContextInstance = value; }
    }

    //starting User Session
    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "C:\\Path\\Data.csv", "Data#csv", DataAccessMethod.Sequential), DeploymentItem("C:\\Path\\Data.csv"), TestMethod]
    public void smokeTest()
    {
        sUserName = "domain\\"+TestContext.DataRow["user"].ToString();
        sPassword = TestContext.DataRow["password"].ToString();
        prospectClientId = TestContext.DataRow["prospectClientId"].ToString();
        accountNumber = TestContext.DataRow["accountNumber"].ToString();
        correlationId = "startUserSession - " + obj.ToString();

        // Start User Session
        using (this.LogTransaction("t1_startUserSession"))
        {
            ChannelFactory<IAppShellService> cfsus = null;
            try
            {
                using (ChannelBuilder.mPContext(ref appShellServiceClient, "IAppShellService", sUserName, sPassword, 0, null, correlationId, false, effectiveDate, ref cfsus))
                {
                    var userSessionResult = appShellServiceClient.StartUserSession();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                cfsus.Close();
            }
        }
    }
  • Have you solved this problem? If not then please [edit] the question after reading [mcve]. If you have solved the problem then please read http://stackoverflow.com/help/accepted-answer . – AdrianHHH Jun 10 '16 at 11:35

1 Answers1

0

The only call of EndTimer is in the Dispose method and that is not called explicitly in your code. Hence the Dispose method will only be called when the garbage collector wants to call it.

I believe you need to add an explicit call of EndTimer. Perhaps by adding a call of your Dispose method into the finally block. See also this answer.

Community
  • 1
  • 1
AdrianHHH
  • 13,492
  • 16
  • 50
  • 87