コード例 #1
0
        private void CreateClients(BenchmarkRun RunConfiguration)
        {
            lock (m_Lock)
            {
                m_Clients.Clear();
                long requests = RunConfiguration.Requests;
                if (RunConfiguration.Clients <= MAX_THREADS)
                {
                    for (int i = 0; i < RunConfiguration.Clients; i++)
                    {
                        if (i + 1 >= RunConfiguration.Clients)
                        {
                            m_Clients.Add(new BenchmarkClient(requests, 1));
                            requests = 0;
                        }
                        else
                        {
                            long clientRequests = Math.Min(requests, RunConfiguration.Requests / Math.Max(1, RunConfiguration.Clients));
                            m_Clients.Add(new BenchmarkClient(clientRequests, 1));

                            requests -= clientRequests;
                        }
                    }
                }
                else
                {
                    long simultaneosRequests = RunConfiguration.Clients;
                    for (int i = 0; i < MAX_THREADS; i++)
                    {
                        if (i + 1 >= MAX_THREADS)
                        {
                            m_Clients.Add(new BenchmarkClient(requests, simultaneosRequests));
                            requests            = 0;
                            simultaneosRequests = 0;
                        }
                        else
                        {
                            long clientRequests            = Math.Min(requests, RunConfiguration.Requests / Math.Max(1, MAX_THREADS));
                            long clientSimultaneosRequests = Math.Min(simultaneosRequests, RunConfiguration.Clients / Math.Max(1, MAX_THREADS));
                            m_Clients.Add(new BenchmarkClient(clientRequests, clientSimultaneosRequests));

                            requests            -= clientRequests;
                            simultaneosRequests -= clientSimultaneosRequests;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void PrintResults()
        {
            BenchmarkRun run = m_CurrentRun ?? m_Configuration.Runs.Last();

            File.AppendAllText(OUTPUT_FILE, $"{m_Configuration.ApiBase};{m_Configuration.SqlImage.SqlFilePath};{run.Clients};{run.Requests};{TotTime.TotalMilliseconds};{MinTime.TotalMilliseconds};{MaxTime.TotalMilliseconds};{AvgTime.TotalMilliseconds};{SucceededRequests};{FailedRequests}{Environment.NewLine}");

            Console.Write(
                $@"Benchmark Results:
[TotTime] {TotTime.TotalMilliseconds} ms
[MinTime] {MinTime.TotalMilliseconds} ms
[MaxTime] {MaxTime.TotalMilliseconds} ms
[AvgTime] {AvgTime.TotalMilliseconds} ms
[Success] {SucceededRequests} ({string.Format("{0:P2}", SucceededRequests / (double)(SucceededRequests + FailedRequests))})
[Failure] {FailedRequests} ({string.Format("{0:P2}", FailedRequests / (double)(SucceededRequests + FailedRequests))})
"
                );
        }
コード例 #3
0
        private void StartNextRun()
        {
            lock (m_Lock)
            {
                StopClients();
                PrintResults();

                if (m_CurrentRepetitions >= m_CurrentRun.Repetitions)
                {
                    m_CurrentRun         = NextRun();
                    m_CurrentRepetitions = 0;
                }

                if (m_CurrentRun == null)
                {
                    Stop();
                    return;
                }

                CreateClients(m_CurrentRun);
                StartClients();
            }
        }