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; } } }
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; }
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()
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()); }
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); }
public void LogFinish() { if (!logFinished) { DisplayItems.Add("Logs", string.Join(",", LogMessageItemList)); DisplayItems.Add("ES", ElapsedMilliseconds.ToString()); } }
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()); }
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"); } }
/// <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 { } }
public override string ToString() { return($"[{StackHeight.ToString()}]{ElapsedMilliseconds.ToString()} 毫秒"); }
public override string ToString() { return(string.Format("[ProfilerWatcher] {0}: {1}ms", msg, ElapsedMilliseconds.ToString())); }