コード例 #1
0
ファイル: frmMain.cs プロジェクト: vamsitp/ab-viz
        private void StartBenchmark()
        {
            if (!string.IsNullOrEmpty(txtUrl.Text) && Uri.IsWellFormedUriString(txtUrl.Text, UriKind.Absolute))
            {
                var arguments = GetArguments();

                if (null != arguments)
                {
                    _ApacheBench               = new ApacheBench(txtUrl.Text, arguments);
                    _ApacheBench.InProgress   += ApacheBench_InProgress;
                    _ApacheBench.DataReceived += ApacheBench_DataReceived;
                    _ApacheBench.Completed    += ApacheBench_Completed;

                    lblToolStripStatus.Text      = string.Format("Started Run {0} ...", _RepeatIndex + 1);
                    pbToolStripProgressBar.Value = 0;
                    btnCancel.Visible            = true;
                    if (!_ApacheBench.Start())
                    {
                        MessageBox.Show("Error starting 'ab.exe'", "Error Starting", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                txtUrl.Focus();
                txtUrl.SelectionStart  = 0;
                txtUrl.SelectionLength = txtUrl.Text.Length;
                //toolTip1.ToolTipTitle = "Please enter valid URL";
                toolTip1.Show("Please enter valid URL", txtUrl, 3000);
                ToggleControls();
            }
        }
コード例 #2
0
ファイル: ApacheBench.cs プロジェクト: claytonjr/ab-viz
        /// <summary>
        /// Runs the ApacheBench in sync.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="arguments">The arguments.</param>
        /// <returns>The data on StandardOutput</returns>
        public static string RunSync(string url, params KeyValuePair <string, string>[] arguments)
        {
            string output = string.Empty;

            using (var ab = new ApacheBench(url, arguments)) {
                if (ab.Start())
                {
                    while (!ab.HasExited)
                    {
                        ;
                    }
                    output = ab.StandardOutput;
                }
            }
            return(output);
        }