Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

LoadTestGoalBasedLoadProfile Class

 

Represents the load profile of a load test that has a goal-based load pattern.

Namespace:   Microsoft.VisualStudio.TestTools.LoadTesting
Assembly:  Microsoft.VisualStudio.QualityTools.LoadTestFramework (in Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll)

System.Object
  Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestLoadProfile
    Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestGoalBasedLoadProfile

[SerializableAttribute]
public class LoadTestGoalBasedLoadProfile : LoadTestLoadProfile

NameDescription
System_CAPS_pubmethodLoadTestGoalBasedLoadProfile()

Initializes a new instance of the LoadTestGoalBasedLoadProfile class.

NameDescription
System_CAPS_pubpropertyCategoryName

Gets or sets a performance counter category to monitor.

System_CAPS_pubpropertyCounterName

Gets or sets the performance counter to monitor.

System_CAPS_pubpropertyHigherValuesBetter

Set this Boolean value to true when the performance counter that is specified by the Category and Counter properties is a performance counter for which a lower value indicates a higher usage of a resource.

System_CAPS_pubpropertyInitialUserCount

Gets or sets the initial user count. This is the number of virtual users to run at the start of the load test before the user load is adjusted, based on the specified goal.

System_CAPS_pubpropertyInstanceName

Gets or sets the performance counter instance to monitor.

System_CAPS_pubpropertyMachineName

Gets or sets the name of the computer to monitor.

System_CAPS_pubpropertyMaxTargetValue

Gets or sets an upper limit to target. Load is increased or decreased to keep the counter below this value.

System_CAPS_pubpropertyMaxUserCount

Gets or sets the maximum user count. The load cannot not exceed this value after the goal is met.(Overrides LoadTestLoadProfile.MaxUserCount.)

System_CAPS_pubpropertyMaxUserCountDecrease

Gets or sets the maximum amount by which to reduce the user load.

System_CAPS_pubpropertyMaxUserCountIncrease

Gets or sets the maximum amount by which to increase the user load.

System_CAPS_pubpropertyMinTargetValue

Gets or sets the lower limit to target for the goal-based load pattern.

System_CAPS_pubpropertyMinUserCount

Gets or sets the minimum user count. The load cannot go below this value even to satisfy the goal.(Overrides LoadTestLoadProfile.MinUserCount.)

System_CAPS_pubpropertyScenarioName

Gets or sets the name of the scenario in the load test that the load profile implementation is controlling.(Inherited from LoadTestLoadProfile.)

System_CAPS_pubpropertyStopAdjustingAtGoal

true indicates that the test must stop adjusting user load. false indicates that the test must continue to adjust the user load throughout the test if that is required to keep the specified performance counter value in the target range.

NameDescription
System_CAPS_pubmethodCheckIfProfileCanBeModified(String)

Throws an exception if the profile property is not yet ready to be modified.(Inherited from LoadTestLoadProfile.)

System_CAPS_pubmethodCopy()

Returns a copy of the current object so it can be modified and assigned to the LoadTestScenario.LoadProfile property. (Inherited from LoadTestLoadProfile.)

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetLoad(Int32)

Returns the user load that should be used at the current time in the load test based on the value of elapsedSeconds since the start of the load test that is passed as an argument. (Overrides LoadTestLoadProfile.GetLoad(Int32).)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodRestoreUserCountAfterRestart(Int32)

Restores the current (after restart) user count to the value it had before the restart. (Overrides LoadTestLoadProfile.RestoreUserCountAfterRestart(Int32).)

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodValidate()

Throws an InvalidLoadProfileException if the LoadProfile object has properties that are inconsistent or not valid. It also displays an appropriate message.(Overrides LoadTestLoadProfile.Validate().)

Legacy Code Example

In the following example, a Load Test Plug-in constructs a GoadBasedLoadProfile object and assigns it to the LoadTestScenario. It also assigns a value for DelayBetweenIterations to the LoadTestScenario in the Initialize() method.

using Microsoft.VisualStudio.TestTools.LoadTesting;
public class LoadTestPluginInitChangeProfile : ILoadTestPlugin
{
    public void Initialize(LoadTest loadTest)
    {
        LoadTestGoalBasedLoadProfile goalLoadProfile = new LoadTestGoalBasedLoadProfile();
        goalLoadProfile.MachineName = Environment.MachineName;
        goalLoadProfile.CategoryName = "Processor";
        goalLoadProfile.CounterName = "% Processor Time";
        goalLoadProfile.InstanceName = "_Total";
        goalLoadProfile.InitialUserCount = 5;
        goalLoadProfile.MinUserCount = 1;
        goalLoadProfile.MaxUserCount = 100;
        goalLoadProfile.MaxUserCountIncrease = 10;
        goalLoadProfile.MaxUserCountDecrease = 5;
        goalLoadProfile.MinTargetValue = 20;
        goalLoadProfile.MaxTargetValue = 25;

        // This example assumes that there is only one scenario
        loadTest.Scenarios[0].LoadProfile = goalLoadProfile;
        loadTest.Scenarios[0].DelayBetweenIterations = 5;
    }
}

In the following example, a Load Test Plug-In modifies selected properties of a GoalBasedLoadProfile in the HeartbeatEvent handler. This approach works only if the load profile that is specified in the .loadtest file is a Goal-Based Load Pattern.

using Microsoft.VisualStudio.TestTools.LoadTesting;

public class LoadTestPluginChangeGoal : ILoadTestPlugin
{
    private LoadTest m_loadTest;
    private LoadTestScenario m_scenario1;
    private bool m_goalChanged;

    public void Initialize(LoadTest loadTest)
    {
        m_loadTest = loadTest;
        // This example assume there is only one scenario
        m_scenario1 = loadTest.Scenarios[0];
        m_loadTest.Heartbeat += new   EventHandler<HeartbeatEventArgs>(m_loadTest_Heartbeat);
    }

    void m_loadTest_Heartbeat(object sender, HeartbeatEventArgs e)
    {
        if (e.ElapsedSeconds >= 60 && !m_goalChanged)
        {
            LoadTestGoalBasedLoadProfile goalLoadProfile = 
                m_scenario1.LoadProfile.Copy() 
                    as LoadTestGoalBasedLoadProfile;
            goalLoadProfile.MinTargetValue = 50;
            goalLoadProfile.MaxTargetValue = 60;
            m_scenario1.LoadProfile = goalLoadProfile;
            m_goalChanged = true;
        }
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: