コード例 #1
0
 public void LogFinish()
 {
     lock (lockObj)
     {
         if (!logFinished)
         {
             if (DisplayItems == null)
             {
                 DisplayItems = new Dictionary <string, string>();
             }
             DisplayItems.Add("Url", RequestURL);
             DisplayItems.Add("Method", HttpMethod);
             DisplayItems.Add("Logs", string.Join(",", LogMessageItemList)?.TrimEnd('|') ?? "无");
             DisplayItems.Add("ES", ElapsedMilliseconds.ToString());
             if (!string.IsNullOrWhiteSpace(Params))
             {
                 Message += $"{Environment.NewLine}请求参数:{Params}";
             }
             if (!string.IsNullOrWhiteSpace(RespContent))
             {
                 Message += $"{Environment.NewLine}返回结果:{RespContent}";
             }
             if (ClientIPList != null)
             {
                 DisplayItems.Add("CIP", string.Join(",", ClientIPList));
             }
             logFinished = true;
         }
     }
 }
コード例 #2
0
        public void LogFinish()
        {
            if (logFinished)
            {
                return;
            }
            if (DisplayItems == null)
            {
                DisplayItems = new Dictionary <string, string>();
            }

            DisplayItems.Add("Url", RequestURL);
            DisplayItems.Add("Method", HttpMethod);
            DisplayItems.Add("ES", ElapsedMilliseconds.ToString());
            if (LogMessageItemList != null && LogMessageItemList.Count > 0)
            {
                DisplayItems.Add("Logs", string.Join(",", LogMessageItemList)?.TrimEnd('|') ?? "无");
            }
            if (ClientIPList != null)
            {
                DisplayItems.Add("CIP", string.Join(",", ClientIPList));
            }
            if (!string.IsNullOrWhiteSpace(Params))
            {
                Message += Environment.NewLine + $"请求参数:{Environment.NewLine}{Params}";
            }
            CutRespContent();
            logFinished = true;
        }
コード例 #3
0
        public bool IsInteresting(ActionConfiguration configuration = null)
        {
            if (configuration == null)
            {
                return(true);
            }
            if (!configuration.Enabled)
            {
                return(false);
            }

            if (!configuration.Time.Enabled || ElapsedMilliseconds.GetValueOrDefault(-1) < configuration.Time.MinimumMilliseconds)
            {
                ElapsedMilliseconds = null;
            }

            if (!configuration.CPU.Enabled || AverageCPU.GetValueOrDefault(-1) < configuration.CPU.MinimumPercentage)
            {
                ElapsedMilliseconds = null;
            }

            if (!configuration.RAM.Enabled || AverageRAM.GetValueOrDefault(-1) < configuration.RAM.MinimumBytes)
            {
                AverageRAM = null;
            }

            return(ElapsedMilliseconds.HasValue || AverageCPU.HasValue || AverageRAM.HasValue);
        }//end IsInteresting()
コード例 #4
0
        public string ToResultsString()
        {
            var sb = new StringBuilder();

            sb.AppendLine("=== Principal variations ===");

            var index = 0;

            foreach (var principalVariation in PrincipalVariations)
            {
                var time = ElapsedMilliseconds.ElementAt(index);

                sb.Append($"{index + 1} {time}ms");

                foreach (var move in principalVariation)
                {
                    sb.Append($" {move.GetNotation()} ");
                }

                sb.AppendLine();

                ++index;
            }

            sb.AppendLine("=== Move evaluations ===");

            foreach (var moveEvaluation in MoveEvaluations.OrderByDescending(x => x.Score))
            {
                sb.AppendLine($"{moveEvaluation.Move.From} {moveEvaluation.Move.To} {moveEvaluation.Score}");
            }

            return(sb.ToString());
        }
コード例 #5
0
        public bool IsInteresting(DataItemConfiguration configuration = null)
        {
            if (configuration == null)
            {
                return(true);
            }
            if (!configuration.Enabled)
            {
                return(false);
            }

            if (!configuration.Time.Enabled || ElapsedMilliseconds.GetValueOrDefault(-1) < configuration.Time.MinimumMilliseconds)
            {
                ElapsedMilliseconds = null;
            }

            if (!configuration.Size.Enabled || DataSize.GetValueOrDefault(-1) < configuration.Size.MinimumBytes)
            {
                DataSize = null;
            }

            if (configuration.Database == null || NHStatistics?.IsInteresting(configuration.Database) != true)
            {
                NHStatistics = null;
            }

            var isInteresting =
                (
                    ElapsedMilliseconds.HasValue || DataSize.HasValue || NHStatistics != null
                );

            return(isInteresting);
        }
コード例 #6
0
 public void LogFinish()
 {
     if (!logFinished)
     {
         DisplayItems.Add("Logs", string.Join(",", LogMessageItemList));
         DisplayItems.Add("ES", ElapsedMilliseconds.ToString());
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: Bhu1Singh/cs-sorting-algos
        public static (TR, string) Performance <T, TR>(Func <T, TR> function, T arg)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var result = function(arg);

            sw.Stop();
            return(result, sw.ElapsedMilliseconds.ToString());
        }
コード例 #8
0
ファイル: HttpHelper.cs プロジェクト: blockbasenetwork/cli
        public static async Task <(string, string)> MeasureWebRequest(string endpoint, HttpWebRequest httpWebRequest)
        {
            try
            {
                httpWebRequest.ServerCertificateValidationCallback = delegate { return(true); };
                httpWebRequest.Timeout = 5000;

                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var response     = (HttpWebResponse)httpWebRequest.GetResponse();
                var streamReader = await new StreamReader(response.GetResponseStream()).ReadToEndAsync();
                stopwatch.Stop();

                return(endpoint, stopwatch.ElapsedMilliseconds.ToString());
            }
            catch (Exception)
            {
                return(endpoint, "No response within 5 seconds");
            }
        }
コード例 #9
0
 /// <summary>
 /// 结束日志
 /// </summary>
 public void LogFinish()
 {
     try
     {
         lock (lockObj)
         {
             if (logFinished)
             {
                 return;
             }
             DisplayItems.Add("Url", RequestURL);
             DisplayItems.Add("Method", HttpMethod);
             DisplayItems.Add("ES", ElapsedMilliseconds.ToString());
             if (ClientIPList != null)
             {
                 DisplayItems.Add("CIP", string.Join(",", ClientIPList));
             }
             if (!string.IsNullOrWhiteSpace(Params))
             {
                 Message += $"\n请求参数:\n  {Params}";
             }
             bool isNewLine = true;
             if (LogMessageItemList != null && LogMessageItemList.Count > 0)
             {
                 isNewLine = false;
                 Message  += $"\n其他信息:\n{string.Join("", LogMessageItemList.OrderBy(x => x.LogIndex))}";
             }
             //if (RespContent.Length > 2000)
             //{
             //    RespContent = RespContent.Substring(0, 2000);
             //}
             Message    += (isNewLine ? "\n" : string.Empty) + $"返回参数:\n  {RespContent}";
             logFinished = true;
         }
     }
     catch { }
 }
コード例 #10
0
ファイル: NTStopwatch.cs プロジェクト: UcAspNet/ntminer
 public override string ToString()
 {
     return($"[{StackHeight.ToString()}]{ElapsedMilliseconds.ToString()} 毫秒");
 }
コード例 #11
0
ファイル: ProfilerWatcher.cs プロジェクト: cnscj/THSTG
 public override string ToString()
 {
     return(string.Format("[ProfilerWatcher] {0}: {1}ms", msg, ElapsedMilliseconds.ToString()));
 }