Browse Source
DoEvents() called very often. New class for logging time measurements to the console. If one OnPause delegate resumes process, remaining delegates are not called. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2906 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
13 changed files with 177 additions and 140 deletions
@ -1,77 +0,0 @@
@@ -1,77 +0,0 @@
|
||||
// <file>
|
||||
// <copyright license="BSD-new" see="prj:///COPYING"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
using Debugger.Expressions; |
||||
|
||||
namespace Debugger.AddIn.TreeModel |
||||
{ |
||||
public static partial class Util |
||||
{ |
||||
static DateTime nextDoEventsTime = Debugger.Util.HighPrecisionTimer.Now; |
||||
const double workLoad = 0.75; // Fraction of getting variables vs. repainting
|
||||
const double maxFPS = 30; // this prevents too much drawing on good machine
|
||||
const double maxWorkTime = 150; // ms this ensures minimal response on bad machine
|
||||
|
||||
public static void ResetDoEventsStartTime() |
||||
{ |
||||
nextDoEventsTime = Debugger.Util.HighPrecisionTimer.Now.AddMilliseconds(1000 / maxFPS); |
||||
} |
||||
|
||||
public static void ForceDoEvents() |
||||
{ |
||||
nextDoEventsTime = DateTime.MinValue; |
||||
DoEvents(); |
||||
} |
||||
|
||||
public static void DoEvents() |
||||
{ |
||||
if (Debugger.Util.HighPrecisionTimer.Now > nextDoEventsTime) { |
||||
DateTime start = Debugger.Util.HighPrecisionTimer.Now; |
||||
LoggingService.InfoFormatted("Application.DoEvents()"); |
||||
Application.DoEvents(); |
||||
DateTime end = Debugger.Util.HighPrecisionTimer.Now; |
||||
double doEventsDuration = (end - start).TotalMilliseconds; |
||||
double minWorkTime = 1000 / maxFPS - doEventsDuration; // ms
|
||||
double workTime = (doEventsDuration / (1 - workLoad)) * workLoad; |
||||
workTime = Math.Max(minWorkTime, Math.Min(maxWorkTime, workTime)); // Clamp
|
||||
nextDoEventsTime = end.AddMilliseconds(workTime); |
||||
double fps = 1000 / (doEventsDuration + workTime); |
||||
// LoggingService.InfoFormatted("Rendering: {0} ms => work budget: {1} ms ({2:f1} FPS)", doEventsDuration, workTime, fps);
|
||||
} |
||||
} |
||||
|
||||
public static AbstractNode CreateNode(Expression expression) |
||||
{ |
||||
try { |
||||
Value val = expression.Evaluate(WindowsDebugger.DebuggedProcess.SelectedStackFrame); |
||||
return new ValueNode(val); |
||||
} catch (GetValueException e) { |
||||
return new ErrorNode(expression, e); |
||||
} |
||||
} |
||||
|
||||
public static WindowsDebugger WindowsDebugger { |
||||
get { |
||||
return (WindowsDebugger)DebuggerService.CurrentDebugger; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class AbortedBecauseDebugeeStateExpiredException: System.Exception |
||||
{ |
||||
public AbortedBecauseDebugeeStateExpiredException(): base() |
||||
{ |
||||
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
// <file>
|
||||
// <copyright license="BSD-new" see="prj:///COPYING"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
using Debugger.Expressions; |
||||
|
||||
namespace Debugger.AddIn.TreeModel |
||||
{ |
||||
public static partial class Utils |
||||
{ |
||||
public static void DoEvents(DebuggeeState debuggeeState) |
||||
{ |
||||
if (debuggeeState == null) { |
||||
throw new ArgumentNullException(); |
||||
} |
||||
if (debuggeeState.HasExpired) { |
||||
throw new System.Exception("State is expired before DoEvents"); |
||||
} |
||||
//using(new PrintTimes("Application.DoEvents()"))
|
||||
{ |
||||
Application.DoEvents(); |
||||
} |
||||
if (debuggeeState.HasExpired) { |
||||
LoggingService.Info("Aborted because debuggee resumed"); |
||||
throw new AbortedBecauseDebuggeeResumedException(); |
||||
} |
||||
} |
||||
|
||||
public static AbstractNode CreateNode(Expression expression) |
||||
{ |
||||
try { |
||||
Value val = expression.Evaluate(WindowsDebugger.DebuggedProcess.SelectedStackFrame); |
||||
return new ValueNode(val); |
||||
} catch (GetValueException e) { |
||||
return new ErrorNode(expression, e); |
||||
} |
||||
} |
||||
|
||||
public static WindowsDebugger WindowsDebugger { |
||||
get { |
||||
return (WindowsDebugger)DebuggerService.CurrentDebugger; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class AbortedBecauseDebuggeeResumedException: System.Exception |
||||
{ |
||||
public AbortedBecauseDebuggeeResumedException(): base() |
||||
{ |
||||
|
||||
} |
||||
} |
||||
|
||||
public class PrintTimes: PrintTime |
||||
{ |
||||
public PrintTimes(string text): base(text + " - end") |
||||
{ |
||||
LoggingService.InfoFormatted("{0} - start", text); |
||||
} |
||||
} |
||||
|
||||
public class PrintTime: IDisposable |
||||
{ |
||||
string text; |
||||
DateTime start; |
||||
|
||||
public PrintTime(string text) |
||||
{ |
||||
this.text = text; |
||||
this.start = Debugger.Util.HighPrecisionTimer.Now; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
TimeSpan dur = Debugger.Util.HighPrecisionTimer.Now - start; |
||||
LoggingService.InfoFormatted("{0} ({1} ms)", text, dur.TotalMilliseconds); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue