Beispiel #1
0
        private ClientAPIPerfNumbers GetClientApiLatencyData(IEnumerable <ResultOfTest> apiDetails, int testDurationInSec)
        {
            double sum   = 0.0;
            int    count = 0;
            ClientAPIPerfNumbers clientApiPerfNumbers = new ClientAPIPerfNumbers();

            foreach (ResultOfTest apiDetail in apiDetails)
            {
                count++;
                clientApiPerfNumbers.ApiName = apiDetail.ApiName;

                if ((apiDetail.TotalExecutionTime != String.Empty) &&
                    (apiDetail.TotalExecutionTime != null) &&
                    (apiDetail.TotalExecutionTime != " "))
                {
                    double value = Double.Parse(apiDetail.TotalExecutionTime);
                    if (value > 0)
                    {
                        sum += value;
                    }

                    if (value > clientApiPerfNumbers.MaxLatency)
                    {
                        clientApiPerfNumbers.MaxLatency = value;
                    }

                    if (value < clientApiPerfNumbers.MinLatency)
                    {
                        clientApiPerfNumbers.MinLatency = value;
                    }
                }
            }

            clientApiPerfNumbers.AvgLatency = sum / count;

            if (double.IsNaN(clientApiPerfNumbers.AvgLatency))
            {
                clientApiPerfNumbers.AvgLatency = 0.0;
            }

            clientApiPerfNumbers.MinLatency = Math.Round(clientApiPerfNumbers.MinLatency, 2);
            clientApiPerfNumbers.AvgLatency = Math.Round(clientApiPerfNumbers.AvgLatency, 2);
            clientApiPerfNumbers.MaxLatency = Math.Round(clientApiPerfNumbers.MaxLatency, 2);
            clientApiPerfNumbers.TotalCalls = count;
            clientApiPerfNumbers.Throughput = Math.Round((Convert.ToDouble(count) / Convert.ToDouble(testDurationInSec)), 2);
            return(clientApiPerfNumbers);
        }
        private ClientAPIPerfNumbers GetClientApiLatencyData(IEnumerable<ResultOfTest> apiDetails, int testDurationInSec)
        {
            double sum = 0.0;
            int count = 0;
            ClientAPIPerfNumbers clientApiPerfNumbers = new ClientAPIPerfNumbers();

            foreach (ResultOfTest apiDetail in apiDetails)
            {
                count++;
                clientApiPerfNumbers.ApiName = apiDetail.ApiName;

                if ((apiDetail.TotalExecutionTime != String.Empty) &&
                    (apiDetail.TotalExecutionTime != null) &&
                    (apiDetail.TotalExecutionTime != " "))
                {
                    double value = Double.Parse(apiDetail.TotalExecutionTime);
                    if (value > 0)
                    {
                        sum += value;
                    }

                    if (value > clientApiPerfNumbers.MaxLatency)
                    {
                        clientApiPerfNumbers.MaxLatency = value;
                    }

                    if (value < clientApiPerfNumbers.MinLatency)
                    {
                        clientApiPerfNumbers.MinLatency = value;
                    }
                }
            }

            clientApiPerfNumbers.AvgLatency = sum / count;

            if (double.IsNaN(clientApiPerfNumbers.AvgLatency))
            {
                clientApiPerfNumbers.AvgLatency = 0.0;
            }

            clientApiPerfNumbers.MinLatency = Math.Round(clientApiPerfNumbers.MinLatency, 2);
            clientApiPerfNumbers.AvgLatency = Math.Round(clientApiPerfNumbers.AvgLatency, 2);
            clientApiPerfNumbers.MaxLatency = Math.Round(clientApiPerfNumbers.MaxLatency, 2);
            clientApiPerfNumbers.TotalCalls = count;
            clientApiPerfNumbers.Throughput = Math.Round((Convert.ToDouble(count) / Convert.ToDouble(testDurationInSec)), 2);
            return clientApiPerfNumbers;
        }