示例#1
0
        private StepInstance CreateStepInstance(Profile profile, ProfileCounters counters, StepInstance parentStepInstance, AndStep step)
        {
            var stepInstance = new AndStepInstance(this, parentStepInstance, step);

            CreateChildStepInstances(stepInstance, step, profile, counters);
            return(stepInstance);
        }
示例#2
0
        private static ProfileCounters CreateCounters(ScenarioCounters scenarioCounters, Profile profile)
        {
            var counters = new ProfileCounters(scenarioCounters, profile.Name, profile.Enabled);

            foreach (var step in profile.Steps)
            {
                AddCounters(counters, profile, step);
            }
            return(counters);
        }
示例#3
0
 private StepInstance CreateStepInstance(Profile profile, ProfileCounters counters, StepInstance parentStepInstance, Step step)
 {
     if (step is ComponentStep)
     {
         return(CreateStepInstance(counters, parentStepInstance, (ComponentStep)step));
     }
     if (step is OrStep)
     {
         return(CreateStepInstance(profile, counters, parentStepInstance, (OrStep)step));
     }
     if (step is AndStep)
     {
         return(CreateStepInstance(profile, counters, parentStepInstance, (AndStep)step));
     }
     return(null);
 }
示例#4
0
        public ProfileInstance(Profile profile, ProfileCounters counters, int user, int totalUsers)
        {
            _profile    = profile;
            _user       = user;
            _totalUsers = totalUsers;
            _counters   = counters;
            _iteration  = counters.NextIteration;

            // Create the test fixture to run the profile.

            _testFixture = Container.Current.Resolve <IProfileTestFixture>(_profile.TestFixture);

            // Create the step hierarchy.

            var rootStep = new AndStepInstance(this, null, new AndStep());

            CreateChildStepInstances(rootStep, profile.Steps, profile, counters);
            CurrentStep = rootStep;
        }
示例#5
0
        private static void AddCounters(ProfileCounters profileCounters, Profile profile, Step step)
        {
            var componentStep = step as ComponentStep;

            if (componentStep != null)
            {
                profileCounters.Add(componentStep.Name, new StepCounters(profileCounters, profile.Name, componentStep.Name, step.Enabled));
                return;
            }

            var stepList = step as StepList;

            if (stepList != null)
            {
                foreach (var childStep in stepList)
                {
                    AddCounters(profileCounters, profile, childStep);
                }
            }
        }
示例#6
0
        private StepInstance CreateStepInstance(ProfileCounters counters, StepInstance parentStepInstance, ComponentStep step)
        {
            // Look for the method.

            MethodInfo endMethod   = null;
            var        beginMethod = _testFixture.GetType().GetMethod(step.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding);

            if (beginMethod == null)
            {
                // Look for a Begin-End pair.

                beginMethod = _testFixture.GetType().GetMethod("Begin" + step.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding);
                if (beginMethod == null)
                {
                    throw new ApplicationException("Method '" + step.Name + "' not found on profile '" + _testFixture.GetType().FullName + ".");
                }

                endMethod = _testFixture.GetType().GetMethod("End" + step.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding);
            }

            return(new ComponentStepInstance(this, parentStepInstance, step, beginMethod, endMethod, counters.StepCounters[step.Name]));
        }
示例#7
0
        public StepCounters(ProfileCounters profileCounters, string profile, string name, bool enabled)
        {
            _profileCounters = profileCounters;

            var instance = profile + ":" + name;

            _enabled            = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.Enabled, instance);
            _currentlyExecuting = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.CurrentlyExecuting, instance);
            _totalCalls         = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.TotalCalls, instance);
            _totalErrors        = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.TotalErrors, instance);
            _callsPerSecond     = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.CallsPerSecond, instance);
            _averageTime        = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.AverageExecutionTime, instance);
            _averageTimeBase    = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.AverageExecutionTimeBase, instance);
            _lastTime           = GetPerformanceCounter(Constants.Counters.Step.Name, Constants.Counters.Step.LastExecutionTime, instance);

            _enabled.RawValue            = enabled ? 1 : 0;
            _currentlyExecuting.RawValue = 0;
            _totalCalls.RawValue         = 0;
            _totalErrors.RawValue        = 0;
            _callsPerSecond.RawValue     = 0;
            _averageTime.RawValue        = 0;
            _averageTimeBase.RawValue    = 0;
            _lastTime.RawValue           = 0;
        }
示例#8
0
 public ProfileData(Profile profile, ProfileCounters counters, int percentage)
 {
     _profile    = profile;
     _counters   = counters;
     _percentage = percentage;
 }
示例#9
0
 private void CreateChildStepInstances(StepInstanceList stepInstance, IEnumerable <Step> steps, Profile profile, ProfileCounters counters)
 {
     foreach (var step in steps)
     {
         var childStepInstance = CreateStepInstance(profile, counters, stepInstance, step);
         if (stepInstance != null)
         {
             stepInstance.Add(childStepInstance);
         }
     }
 }