Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        void IChannelSource.Open()
        {
            const string method = "Open";

            _stopSignal      = new ManualResetEvent(false);
            _pauseSignal     = new ManualResetEvent(false);
            _continueSignal  = new ManualResetEvent(true);
            _pauseSignals    = new[] { _stopSignal, _pauseSignal };
            _continueSignals = new[] { _stopSignal, _continueSignal };

            _stepRunner = new StepRunner();

            _counters = new ScenarioCounters("test", _users);

            // Setup the details for each profile.

            _profileData = new List <ProfileData>();
            var currentPercentage = 0;
            var runnableProfiles  = 0;

            foreach (var profile in _profiles)
            {
                var profileCounters = CreateCounters(_counters, profile);

                // The percentage can be specified down to 0.01% so multiply by 100.

                currentPercentage += profile.Percentage * 100;
                if (profile.Runnable)
                {
                    ++runnableProfiles;
                }

                _profileData.Add(new ProfileData(profile, profileCounters, currentPercentage));
            }

            // Check the percentages.

            if (currentPercentage != 10000)
            {
                throw new InvalidConfigurationValueException(GetType(), method, "percentage", currentPercentage / 100);
            }
            if (runnableProfiles == 0)
            {
                throw new InvalidConfigurationValueException(GetType(), method, "enabled", false);
            }

            _thread = new Thread(Run);
        }
Exemplo n.º 3
0
        public ProfileCounters(ScenarioCounters scenarioCounters, string name, bool enabled)
        {
            _scenarioCounters = scenarioCounters;

            _enabled          = GetPerformanceCounter(Constants.Counters.Profile.Name, Constants.Counters.Profile.Enabled, name);
            _currentlyRunning = GetPerformanceCounter(Constants.Counters.Profile.Name, Constants.Counters.Profile.CurrentlyRunning, name);
            _totalRuns        = GetPerformanceCounter(Constants.Counters.Profile.Name, Constants.Counters.Profile.TotalRuns, name);
            _totalErrors      = GetPerformanceCounter(Constants.Counters.Profile.Name, Constants.Counters.Profile.TotalErrors, name);
            _averageTime      = GetPerformanceCounter(Constants.Counters.Profile.Name, Constants.Counters.Profile.AverageExecutionTime, name);
            _averageTimeBase  = GetPerformanceCounter(Constants.Counters.Profile.Name, Constants.Counters.Profile.AverageExecutionTimeBase, name);
            _lastTime         = GetPerformanceCounter(Constants.Counters.Profile.Name, Constants.Counters.Profile.LastExecutionTime, name);

            _enabled.RawValue          = enabled ? 1 : 0;
            _currentlyRunning.RawValue = 0;
            _totalRuns.RawValue        = 0;
            _totalErrors.RawValue      = 0;
            _averageTime.RawValue      = 0;
            _averageTimeBase.RawValue  = 0;
            _lastTime.RawValue         = 0;
        }