From bd3055466fba176503c3e108c45cedb5ed18aa4b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 3 Oct 2009 13:51:02 +0000 Subject: [PATCH] DocumentUtilitites.GetWordAt: fixed ArgumentOutOfRangeException. Minor improvements to profiler. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5044 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Data/ProfilingDataSQLiteProvider.cs | 4 ++-- .../Profiler/Controller/Data/UnitTestWriter.cs | 15 ++++++++++++--- .../Controller/Data/UnmanagedCallTreeNode.cs | 2 +- .../Misc/Profiler/Controller/Queries/QueryBase.cs | 2 +- .../Base/Project/Src/Editor/DocumentUtilitites.cs | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs b/src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs index d5c081015c..53d07bc0c1 100644 --- a/src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs +++ b/src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs @@ -335,7 +335,7 @@ namespace ICSharpCode.Profiler.Controller.Data } /// - public override IQueryable GetAllCalls(int startIndex, int endIndex) + public override IQueryable GetFunctions(int startIndex, int endIndex) { if (startIndex < 0 || startIndex >= this.DataSets.Count) throw new ArgumentOutOfRangeException("startIndex", startIndex, "Value must be between 0 and " + endIndex); @@ -345,7 +345,7 @@ namespace ICSharpCode.Profiler.Controller.Data SQLiteQueryProvider queryProvider = new SQLiteQueryProvider(this, startIndex, endIndex); var query = queryProvider.CreateQuery(new Filter(AllCalls.Instance, DataSetFilter(startIndex, endIndex))); - return query.Where(c => c.NameMapping.Id != 0); + return query.Where(c => c.NameMapping.Id != 0 && !c.IsThread).MergeByName(); } Expression> DataSetFilter(int startIndex, int endIndex) diff --git a/src/AddIns/Misc/Profiler/Controller/Data/UnitTestWriter.cs b/src/AddIns/Misc/Profiler/Controller/Data/UnitTestWriter.cs index d8c7ad8407..e3ee17d0cc 100644 --- a/src/AddIns/Misc/Profiler/Controller/Data/UnitTestWriter.cs +++ b/src/AddIns/Misc/Profiler/Controller/Data/UnitTestWriter.cs @@ -12,13 +12,18 @@ using System.Collections.Generic; namespace ICSharpCode.Profiler.Controller.Data { /// - /// Description of UnitTestWriter. + /// Filters the data being written to remove NUnit internals and show the unit tests more clearly. /// public class UnitTestWriter : IProfilingDataWriter { IProfilingDataWriter targetWriter; - string[] unitTestNames; + HashSet unitTestNames; + /// + /// Creates a new UnitTestWriter instance. + /// + /// The target IProfilingDataWriter where the output should be written to. + /// The fully qualified names of the unit test methods. public UnitTestWriter(IProfilingDataWriter targetWriter, string[] unitTestNames) { if (targetWriter == null) @@ -28,7 +33,7 @@ namespace ICSharpCode.Profiler.Controller.Data throw new ArgumentNullException("unitTestNames"); this.targetWriter = targetWriter; - this.unitTestNames = unitTestNames; + this.unitTestNames = new HashSet(unitTestNames); } sealed class UnitTestDataSet : IProfilingDataSet @@ -47,11 +52,13 @@ namespace ICSharpCode.Profiler.Controller.Data public CallTreeNode RootNode { get; private set; } } + /// public int ProcessorFrequency { get { return this.targetWriter.ProcessorFrequency; } set { this.targetWriter.ProcessorFrequency = value; } } + /// public void WriteDataSet(IProfilingDataSet dataSet) { if (dataSet == null) @@ -85,11 +92,13 @@ namespace ICSharpCode.Profiler.Controller.Data } } + /// public void WriteMappings(System.Collections.Generic.IEnumerable mappings) { this.targetWriter.WriteMappings(mappings); } + /// public void Close() { this.targetWriter.Close(); diff --git a/src/AddIns/Misc/Profiler/Controller/Data/UnmanagedCallTreeNode.cs b/src/AddIns/Misc/Profiler/Controller/Data/UnmanagedCallTreeNode.cs index c51adb2749..72333c801e 100644 --- a/src/AddIns/Misc/Profiler/Controller/Data/UnmanagedCallTreeNode.cs +++ b/src/AddIns/Misc/Profiler/Controller/Data/UnmanagedCallTreeNode.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.Profiler.Controller.Data children.Sort((a,b) => a.Index.CompareTo(b.Index)); - return children.Cast().AsQueryable(); // TODO : remove Cast<> in .NET 4.0 + return children.AsQueryable(); } } diff --git a/src/AddIns/Misc/Profiler/Controller/Queries/QueryBase.cs b/src/AddIns/Misc/Profiler/Controller/Queries/QueryBase.cs index c595637dcc..f0ce1cfba9 100644 --- a/src/AddIns/Misc/Profiler/Controller/Queries/QueryBase.cs +++ b/src/AddIns/Misc/Profiler/Controller/Queries/QueryBase.cs @@ -40,7 +40,7 @@ namespace ICSharpCode.Profiler.Controller.Queries /// /// Returns all calls. /// - public IQueryable Calls { get { return Root.Descendants; } } + public IQueryable Calls { get { return Provider.GetAllCalls(StartDataSetIndex, EndDataSetIndex); } } /// /// Returns all functions. diff --git a/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs b/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs index efe6bafb50..c936a51e32 100644 --- a/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs +++ b/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs @@ -101,7 +101,7 @@ namespace ICSharpCode.SharpDevelop.Editor /// public static string GetWordAt(this ITextBuffer document, int offset) { - if (offset < 0 || offset > document.TextLength || !IsWordPart(document.GetCharAt(offset))) { + if (offset < 0 || offset >= document.TextLength || !IsWordPart(document.GetCharAt(offset))) { return String.Empty; } int startOffset = offset;