Example #1
0
 // This function is used to dump stat information after SendingStep changed during running.
 // It was not used because it will interleave with other dumping.
 public void ParseMergedDictionary(
     IDictionary <string, long> mergedResult,
     double[] percentileList,
     long latencyStep,
     long latencyMax)
 {
     _endStat = _curStat;
     _curStat = new StatisticDictionary()
     {
         Time = DateTimeOffset.UtcNow,
         Stat = new Dictionary <string, long>(mergedResult)
     };
     if (mergedResult[SignalRConstants.StatisticsEpoch] > 0)
     {
         if (mergedResult[SignalRConstants.StatisticsEpoch] != _epoch)
         {
             if (_prevStat != null)
             {
                 PrintStat(_prevStat, _endStat, percentileList, latencyStep, latencyMax);
             }
             _prevStat = _curStat;
         }
         _epoch = mergedResult[SignalRConstants.StatisticsEpoch];
     }
 }
Example #2
0
        public static void PrintStat(
            StatisticDictionary begin,
            StatisticDictionary end,
            double[] percentileList,
            long latencyStep,
            long latencyMax)
        {
            var elapse      = end.Time - begin.Time;
            var sentMsgSize = end.Stat[SignalRConstants.StatisticsMessageSentSize] -
                              begin.Stat[SignalRConstants.StatisticsMessageSentSize];
            var recvMsgSize = end.Stat[SignalRConstants.StatisticsMessageReceivedSize] -
                              begin.Stat[SignalRConstants.StatisticsMessageReceivedSize];
            var sent = end.Stat[SignalRConstants.StatisticsMessageSent] -
                       begin.Stat[SignalRConstants.StatisticsMessageSent];
            var recv = end.Stat[SignalRConstants.StatisticsMessageReceived] -
                       begin.Stat[SignalRConstants.StatisticsMessageReceived];
            var connection  = end.Stat[SignalRConstants.StatisticsConnectionConnectSuccess];
            var sendingStep = end.Stat[SignalRConstants.StatisticsSendingStep];
            var sendTputs   = sentMsgSize / elapse.TotalSeconds;
            var recvTputs   = recvMsgSize / elapse.TotalSeconds;
            var sendRate    = sent / elapse.TotalSeconds;
            var recvRate    = recv / elapse.TotalSeconds;

            Log.Information($"-----------");
            Log.Information($" Connection/sendingStep: {connection}/{sendingStep} in {elapse.TotalSeconds}s");
            Log.Information($" Messages: requests: {FormatBytesDisplay(sentMsgSize)}, responses: {FormatBytesDisplay(recvMsgSize)}");
            Log.Information($"   Requests/sec: {FormatDoubleValue(sendRate)}");
            Log.Information($"   Responses/sec: {FormatDoubleValue(recvRate)}");
            Log.Information($"   Write throughput: {FormatBytesDisplay(sendTputs)}");
            Log.Information($"   Read throughput: {FormatBytesDisplay(recvTputs)}");
            Log.Information($" Latency:");
            foreach (var p in percentileList)
            {
                var index = FindLatencyLowerBound(end.Stat, p, latencyStep, latencyMax);
                if (index == latencyStep + latencyMax)
                {
                    Log.Information($"  {p * 100}%: >= 1s");
                }
                else if (index == latencyStep)
                {
                    Log.Information($"  {p * 100}%: < {index} ms");
                }
                else
                {
                    Log.Information($"  {p * 100}%: < {index + latencyStep} ms");
                }
            }
        }