Esempio n. 1
0
 private void startButton_Click(object sender, EventArgs e)
 {
     if (Requests != null && Requests.Count > 0)
     {
         if (requestProgressBar.Value == 0 && Runner == null)
         {
             Runner = new TestRunner(this.Requests, (int)iterations.Value, (int)workers.Value);
             TestWorker.RequestsTimeout = (int)timeout.Value;
             requestProgressBar.Maximum = Runner.MaxRequests;
             Runner.Start();
         }
         else
         {
             Runner.Restart();
         }
         requestGroupBox.Enabled = false;
         startButton.Enabled = false;
         stopButton.Enabled = true;
         pauseButton.Enabled = true;
         loadButton.Enabled = false;
         stopButton.Select();
         this.stopwatch.Start();
         refreshTimer.Start();
         TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Normal);
     }
 }
Esempio n. 2
0
        private void refreshTimer_Tick(object sender, EventArgs e)
        {
            if(Runner != null)
            {
                estimatedRemainingTime.Text = "instant: " + Runner.EstimatedRemainingTime + " / average: "
                    + TimeSpan.FromTicks((long)((double)this.stopwatch.ElapsedTicks * (double)Runner.MaxRequests / (double)Runner.RequestCount) - this.stopwatch.ElapsedTicks)
                    + " / elapsed:" + this.stopwatch.Elapsed;
                activeRunners.Text = Runner.WaitingWorkerCount + " / " + Runner.RunningWorkerCount;
                requestCount.Text = Runner.RequestCount + " / " + Runner.MaxRequests;
                requestProgressBar.Value = Runner.RequestCount;
                TaskbarProgress.SetValue(this.Handle, Runner.RequestCount, Runner.MaxRequests);

                if (!Runner.IsRunning && !startButton.Enabled)
                {
                    refreshTimer.Stop();
                    startButton.Enabled = true;
                    stopButton.Enabled = false;
                    if (pauseRequested)
                    {
                        TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Paused);
                        pauseRequested = false;
                    }
                    else
                    {
                        requestProgressBar.Value = 0;
                        TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.NoProgress);
                        estimatedRemainingTime.Text = activeRunners.Text = requestCount.Text = "--";
                        pauseButton.Enabled = false;
                        requestGroupBox.Enabled = true;
                        loadButton.Enabled = true;
                        ResultForm resultForm = new ResultForm(Runner.TestResults);
                        resultForm.Show();
                        Runner = null;
                        this.stopwatch.Reset();
                    }
                }
            }
            else
            {
                refreshTimer.Stop();
            }
        }