public void End() { if (!stopWatch.IsRunning) { Console.WriteLine("Timer already finished"); return; } stopWatch.Stop(); traceList.TotalTime = TimeSpan.FromMilliseconds(stopWatch.ElapsedMilliseconds); if (traceList.TotalTime.TotalSeconds < counter.MinSeconds) { counter.RemoveValue(traceList.ValueIndex); } else { counter.AddTime(traceList.TotalTime); } counter = null; if (linkedTrackers is List <IDisposable> ) { foreach (var t in (List <IDisposable>)linkedTrackers) { t.Dispose(); } } else if (linkedTrackers != null) { ((IDisposable)linkedTrackers).Dispose(); } stopWatch.Reset(); }
public void End() { if (counter == null) { Console.WriteLine("Timer already finished"); return; } traceList.TotalTime = DateTime.Now - begin; if (traceList.TotalTime.TotalSeconds < counter.MinSeconds) { counter.RemoveValue(traceList.ValueIndex); } else { counter.AddTime(traceList.TotalTime); } counter = null; if (linkedTrackers is List <IDisposable> ) { foreach (var t in (List <IDisposable>)linkedTrackers) { t.Dispose(); } } else if (linkedTrackers != null) { ((IDisposable)linkedTrackers).Dispose(); } }
public static TimerCounter CreateTimerCounter(string name, string category = null, double minSeconds = 0, bool logMessages = false, string id = null) { TimerCounter c = (TimerCounter)CreateCounter(name, category, logMessages, id, true); c.LogMessages = logMessages; c.MinSeconds = minSeconds; return(c); }
internal TimeCounter(TimerCounter counter) { this.counter = counter; if (counter.Enabled) { traceList = new TimerTraceList(); } Begin(); }
public static TimerCounter CreateTimerCounter(string name, string category, double minSeconds, bool logMessages) { TimerCounter c = (TimerCounter)CreateCounter(name, category, logMessages, true); c.DisplayMode = CounterDisplayMode.Line; c.LogMessages = logMessages; c.MinSeconds = minSeconds; return(c); }
public BaseNRefactoryIssueProvider (NRefactoryIssueProvider parentIssue, SubIssueAttribute subIssue) { this.parentIssue = parentIssue; this.subIssue = subIssue; this.Title = subIssue.Title; this.Description = subIssue.Description; DefaultSeverity = subIssue.Severity.HasValue ? subIssue.Severity.Value : parentIssue.DefaultSeverity; IsEnabledByDefault = subIssue.IsEnabledByDefault.HasValue ? subIssue.IsEnabledByDefault.Value : parentIssue.IsEnabledByDefault; UpdateSeverity (); counter = InstrumentationService.CreateTimerCounter (IdString, "CodeIssueProvider run times"); }
internal TimeCounter(TimerCounter counter, T metadata, CancellationToken cancellationToken) { this.counter = counter; this.metadata = metadata; if (counter.Enabled || metadata != null) { // Store metadata in the traces list. The corresponding CounterValue will get whatever // metadata is assigned there traceList = new TimerTraceList(); traceList.Metadata = metadata?.Properties; } this.cancellationToken = cancellationToken; Begin(); }
public void End() { if (!stopWatch.IsRunning) { Console.WriteLine("Timer already finished"); return; } stopWatch.Stop(); Duration = stopWatch.Elapsed; if (metadata != null && cancellationToken != CancellationToken.None && cancellationToken.IsCancellationRequested) { metadata.Result = CounterResult.UserCancel; } if (counter.LogMessages) { var time = stopWatch.ElapsedMilliseconds; InstrumentationService.LogMessage(string.Format("[{0} (+{1})] END: {2}", time, (time - lastTraceTime), counter.Name)); } if (traceList != null) { traceList.TotalTime = TimeSpan.FromMilliseconds(stopWatch.ElapsedMilliseconds); if (traceList.TotalTime.TotalSeconds < counter.MinSeconds) { counter.RemoveValue(traceList.ValueIndex); } else { counter.AddTime(traceList.TotalTime); } } counter = null; if (linkedTrackers is List <IDisposable> ) { foreach (var t in (List <IDisposable>)linkedTrackers) { t.Dispose(); } } else if (linkedTrackers != null) { ((IDisposable)linkedTrackers).Dispose(); } stopWatch.Reset(); }
public void End() { if (counter == null) { Console.WriteLine("Timer already finished"); return; } traceList.TotalTime = DateTime.Now - begin; if (traceList.TotalTime.TotalSeconds < counter.MinSeconds) { counter.RemoveValue(traceList.ValueIndex); } else { counter.AddTime(traceList.TotalTime); } counter = null; }
public IntrumentationMonitor(TimerCounter counter) { this.counter = counter; }
internal TimeCounter (TimerCounter counter) { this.counter = counter; traceList = new TimerTraceList (); Begin (); }
public void End () { if (!stopWatch.IsRunning) { Console.WriteLine ("Timer already finished"); return; } stopWatch.Stop (); traceList.TotalTime = TimeSpan.FromMilliseconds (stopWatch.ElapsedMilliseconds); if (traceList.TotalTime.TotalSeconds < counter.MinSeconds) counter.RemoveValue (traceList.ValueIndex); else counter.AddTime (traceList.TotalTime); counter = null; if (linkedTrackers is List<IDisposable>) { foreach (var t in (List<IDisposable>)linkedTrackers) t.Dispose (); } else if (linkedTrackers != null) ((IDisposable)linkedTrackers).Dispose (); stopWatch.Reset (); }
void AppendValues (TreeIter parent, TimerCounter c) { Gdk.Pixbuf icon = c.GetIcon (); foreach (CounterValue val in c.GetValues ().Where (val => val.HasTimerTraces)) { string msg = !string.IsNullOrEmpty (val.Message) ? val.Message : c.Name; store.AppendValues (parent, icon, msg, val.Value, (float) val.Duration.TotalMilliseconds, 0f, 0f, 0f, false, null, val, true, true, val.GetTimeColor (c)); } }
public IntrumentationMonitor (TimerCounter counter) { this.counter = counter; }
internal TimeCounter(TimerCounter counter) { this.counter = counter; traceList = new TimerTraceList(); Begin(); }
public virtual IDisposable BeginTimer (TimerCounter counter, CounterValue value) { return null; }
void AppendCounter (TreeIter parent, TimerCounter c) { TreeIter it; if (parent.Equals (TreeIter.Zero)) it = store.AppendValues (c.GetIcon (), c.Name, c.Count, (float)c.TotalTime.TotalMilliseconds, (float)c.AverageTime.TotalMilliseconds, (float)c.MinTime.TotalMilliseconds, (float)c.MaxTime.TotalMilliseconds, false, c, null, true, true, normalColor); else it = store.AppendValues (parent, c.GetIcon (), c.Name, c.Count, (float)c.TotalTime.TotalMilliseconds, (float)c.AverageTime.TotalMilliseconds, (float)c.MinTime.TotalMilliseconds, (float)c.MaxTime.TotalMilliseconds, false, c, null, true, true, normalColor); // Dummy node store.AppendValues (it, null, "*"); }
public static IProgressMonitor GetInstrumentedMonitor (IProgressMonitor monitor, TimerCounter counter) { if (enabled) { AggregatedProgressMonitor mon = new AggregatedProgressMonitor (monitor); mon.AddSlaveMonitor (new IntrumentationMonitor (counter), MonitorAction.Tasks | MonitorAction.WriteLog); return mon; } else return monitor; }
public static IProgressMonitor GetInstrumentedMonitor(IProgressMonitor monitor, TimerCounter counter) { if (enabled) { AggregatedProgressMonitor mon = new AggregatedProgressMonitor(monitor); mon.AddSlaveMonitor(new IntrumentationMonitor(counter), MonitorAction.Tasks | MonitorAction.WriteLog); return(mon); } else { return(monitor); } }
public NRefactoryIssueProvider (ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssueProvider issue, IssueDescriptionAttribute attr) { issueProvider = issue; this.attr = attr; providerIdString = issueProvider.GetType ().FullName; Category = GettextCatalog.GetString (attr.Category ?? ""); Title = GettextCatalog.GetString (attr.Title ?? ""); Description = GettextCatalog.GetString (attr.Description ?? ""); DefaultSeverity = attr.Severity; IsEnabledByDefault = attr.IsEnabledByDefault; SetMimeType ("text/x-csharp"); subIssues = issueProvider.SubIssues.Select (subIssue => (BaseCodeIssueProvider)new BaseNRefactoryIssueProvider (this, subIssue)).ToList (); counter = InstrumentationService.CreateTimerCounter (IdString, "CodeIssueProvider run times"); }
public NRefactoryIssueProvider (ICSharpCode.NRefactory.CSharp.Refactoring.CodeIssueProvider issue, IssueDescriptionAttribute attr) { issueProvider = issue; this.attr = attr; providerIdString = issueProvider.GetType ().FullName; Category = GettextCatalog.GetString (attr.Category ?? ""); Title = GettextCatalog.GetString (attr.Title ?? ""); Description = GettextCatalog.GetString (attr.Description ?? ""); DefaultSeverity = attr.Severity; IsEnabledByDefault = attr.IsEnabledByDefault; SetMimeType ("text/x-csharp"); subIssues = issueProvider.SubIssues.Select (subIssue => (BaseCodeIssueProvider)new BaseNRefactoryIssueProvider (this, subIssue)).ToList (); // Additional source of actions var actionProvider = attr.ActionProvider; if (actionProvider != null) { var actionAttr = actionProvider.GetCustomAttributes (typeof(ContextActionAttribute), false); if (actionAttr != null && actionAttr.Length == 1) boundActionProvider = (ICSharpCode.NRefactory.CSharp.Refactoring.CodeActionProvider)Activator.CreateInstance (actionProvider); } counter = InstrumentationService.CreateTimerCounter (IdString, "CodeIssueProvider run times"); }
public virtual IDisposable?BeginTimer(TimerCounter counter, CounterValue value) { return(null); }
public void End () { if (counter == null) { Console.WriteLine ("Timer already finished"); return; } traceList.TotalTime = DateTime.Now - begin; if (traceList.TotalTime.TotalSeconds < counter.MinSeconds) counter.RemoveValue (traceList.ValueIndex); else counter.AddTime (traceList.TotalTime); counter = null; }
public IntrumentationMonitor(TimerCounter counter) { this.counter = counter; logger.TextWritten += HandleLoggerTextWritten; }
public static Gdk.Color GetTimeColor (this CounterValue val, TimerCounter c) { long m = c.AverageTime.Ticks; long v = val.Duration.Ticks; if (v >= m*3) return new Gdk.Color (255, 0, 0); if (v >= m*2) return new Gdk.Color (150, 0, 0); if (v >= (long)((double)m) * 1.5d) return new Gdk.Color (100, 0, 0); if (v >= (long)((double)m) * 1.1d) return new Gdk.Color (50, 0, 0); if (v <= m/3) return new Gdk.Color (0, 255, 0); if (v <= m/2) return new Gdk.Color (0, 150, 0); if (v <= (long)((double)m) * 0.75d) return new Gdk.Color (0, 100, 0); if (v <= (long)((double)m) * 0.90d) return new Gdk.Color (00, 50, 0); return new Gdk.Color (0, 0, 0); }
public IntrumentationMonitor (TimerCounter counter) { this.counter = counter; logger.TextWritten += HandleLoggerTextWritten; }
public void End () { if (counter == null) { Console.WriteLine ("Timer already finished"); return; } traceList.TotalTime = DateTime.Now - begin; if (traceList.TotalTime.TotalSeconds < counter.MinSeconds) counter.RemoveValue (traceList.ValueIndex); else counter.AddTime (traceList.TotalTime); counter = null; if (linkedTrackers is List<IDisposable>) { foreach (var t in (List<IDisposable>)linkedTrackers) t.Dispose (); } else if (linkedTrackers != null) ((IDisposable)linkedTrackers).Dispose (); }