Browse Source

Add unit test project for the profiler.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5019 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
8ef02736b4
  1. 12
      SharpDevelop.Tests.sln
  2. 13
      src/AddIns/Misc/Profiler/Controller/BuildEvents.proj
  3. 19
      src/AddIns/Misc/Profiler/Controller/Data/Linq/OptimizeQueryExpressionVisitor.cs
  4. 2
      src/AddIns/Misc/Profiler/Controller/Data/Linq/QueryAst.cs
  5. 16
      src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs
  6. 23
      src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs
  7. 1
      src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteWriter.cs
  8. 9
      src/AddIns/Misc/Profiler/Controller/Data/SQLiteCallTreeNode.cs
  9. 2
      src/AddIns/Misc/Profiler/Controller/Profiler.Controller.csproj
  10. 2
      src/AddIns/Misc/Profiler/Controller/Properties/AssemblyInfo.cs
  11. 142
      src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Data/CallTreeNodeStub.cs
  12. 83
      src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Data/LinqTests.cs
  13. 2
      src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Data/MetadataTests.cs
  14. 2
      src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Queries/NodePathTests.cs
  15. 20
      src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Profiler.Tests.csproj
  16. 16
      src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

12
SharpDevelop.Tests.sln

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 10 # Visual Studio 10
# SharpDevelop 4.0.0.4979 # SharpDevelop 4.0.0.5015
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
@ -525,6 +525,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Profiler", "Profiler", "{C4
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Tests", "src\AddIns\Misc\Profiler\Tests\Profiler.Tests\Profiler.Tests.csproj", "{068F9531-5D29-49E0-980E-59982A3A0469}"
ProjectSection(ProjectDependencies) = postProject
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
EndProjectSection
EndProject
Project("{0E96FCFA-9DAC-4534-AC18-01A90C368873}") = "Hook", "src\AddIns\Misc\Profiler\Hook\Hook.vcxproj", "{68D5EE3B-0C35-4DF1-BD29-6606851A02C1}" Project("{0E96FCFA-9DAC-4534-AC18-01A90C368873}") = "Hook", "src\AddIns\Misc\Profiler\Hook\Hook.vcxproj", "{68D5EE3B-0C35-4DF1-BD29-6606851A02C1}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.X64Converter", "src\AddIns\Misc\Profiler\X64Converter\Profiler.X64Converter.csproj", "{FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.X64Converter", "src\AddIns\Misc\Profiler\X64Converter\Profiler.X64Converter.csproj", "{FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6}"
@ -957,6 +962,10 @@ Global
{68D5EE3B-0C35-4DF1-BD29-6606851A02C1}.Debug|Win32.ActiveCfg = Debug|Win32 {68D5EE3B-0C35-4DF1-BD29-6606851A02C1}.Debug|Win32.ActiveCfg = Debug|Win32
{68D5EE3B-0C35-4DF1-BD29-6606851A02C1}.Release|Win32.Build.0 = Release|Win32 {68D5EE3B-0C35-4DF1-BD29-6606851A02C1}.Release|Win32.Build.0 = Release|Win32
{68D5EE3B-0C35-4DF1-BD29-6606851A02C1}.Release|Win32.ActiveCfg = Release|Win32 {68D5EE3B-0C35-4DF1-BD29-6606851A02C1}.Release|Win32.ActiveCfg = Release|Win32
{068F9531-5D29-49E0-980E-59982A3A0469}.Debug|Any CPU.Build.0 = Debug|Any CPU
{068F9531-5D29-49E0-980E-59982A3A0469}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{068F9531-5D29-49E0-980E-59982A3A0469}.Release|Any CPU.Build.0 = Release|Any CPU
{068F9531-5D29-49E0-980E-59982A3A0469}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1074,5 +1083,6 @@ Global
{72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F} = {C4035C32-026F-4158-AF15-113EA1EF1960} {72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F} = {C4035C32-026F-4158-AF15-113EA1EF1960}
{FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {C4035C32-026F-4158-AF15-113EA1EF1960} {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {C4035C32-026F-4158-AF15-113EA1EF1960}
{68D5EE3B-0C35-4DF1-BD29-6606851A02C1} = {C4035C32-026F-4158-AF15-113EA1EF1960} {68D5EE3B-0C35-4DF1-BD29-6606851A02C1} = {C4035C32-026F-4158-AF15-113EA1EF1960}
{068F9531-5D29-49E0-980E-59982A3A0469} = {C4035C32-026F-4158-AF15-113EA1EF1960}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

13
src/AddIns/Misc/Profiler/Controller/BuildEvents.proj

@ -1,13 +0,0 @@
<?xml version="1.0"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTarget="Build">
<PropertyGroup>
<PrepareForRunDependsOn>$(PrepareForRunDependsOn);MyPostBuildTarget</PrepareForRunDependsOn>
</PropertyGroup>
<Target Name="MyPostBuildTarget">
<Copy SourceFiles="..\Hook\Win32\$(Configuration)\Hook.dll" DestinationFiles="$(OutputPath)\Hook32.dll" Condition="Exists('..\Hook\Win32\$(Configuration)\Hook.dll')" SkipUnchangedFiles="false" />
<Copy SourceFiles="..\Hook\Win32\$(Configuration)\Hook.pdb" DestinationFiles="$(OutputPath)\Hook32.pdb" Condition="Exists('..\Hook\Win32\$(Configuration)\Hook.pdb')" SkipUnchangedFiles="false" />
<Copy SourceFiles="..\Hook\x64\$(Configuration)\Hook.dll" DestinationFiles="$(OutputPath)\Hook64.dll" Condition="Exists('..\Hook\x64\$(Configuration)\Hook.dll')" SkipUnchangedFiles="false" />
<Copy SourceFiles="..\Hook\x64\$(Configuration)\Hook.pdb" DestinationFiles="$(OutputPath)\Hook64.pdb" Condition="Exists('..\Hook\x64\$(Configuration)\Hook.pdb')" SkipUnchangedFiles="false" />
</Target>
</Project>

19
src/AddIns/Misc/Profiler/Controller/Data/Linq/OptimizeQueryExpressionVisitor.cs

@ -33,12 +33,16 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
protected override Expression VisitExtension(Expression node) protected override Expression VisitExtension(Expression node)
{ {
Filter filter = node as Filter; Filter filter = node as Filter;
MergeByName mergeByName = node as MergeByName;
if (filter != null) if (filter != null)
return VisitFilter(filter); return VisitFilter(filter);
else if (mergeByName != null)
return VisitMergeByName(mergeByName);
else else
return base.VisitExtension(node); return base.VisitExtension(node);
} }
#region Filter optimizations
QueryNode VisitFilter(Filter filter) QueryNode VisitFilter(Filter filter)
{ {
QueryNode result = OptimizeFilter(filter); QueryNode result = OptimizeFilter(filter);
@ -130,9 +134,24 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
else else
return new Filter(target, newConditions.ToArray()); return new Filter(target, newConditions.ToArray());
} }
#endregion
#region MergeByName Optimizations
QueryNode VisitMergeByName(MergeByName merge)
{
// First optimize the Target expression
QueryNode target = Visit(merge.Target);
if (target is MergeByName) {
// x.MergeByName().MergeByName() -> x.MergeByName()
return target;
}
return new MergeByName(target);
}
#endregion
protected override Expression VisitMethodCall(MethodCallExpression node) protected override Expression VisitMethodCall(MethodCallExpression node)
{ {
// Optimize List<int>.Contains when the list has 0 or 1 elements
if (node.Method == KnownMembers.ListOfInt_Contains && node.Object.NodeType == ExpressionType.Constant && node.Arguments[0].Type == typeof(int)) { if (node.Method == KnownMembers.ListOfInt_Contains && node.Object.NodeType == ExpressionType.Constant && node.Arguments[0].Type == typeof(int)) {
List<int> list = (List<int>)((ConstantExpression)node.Object).Value; List<int> list = (List<int>)((ConstantExpression)node.Object).Value;
if (list.Count == 0) if (list.Count == 0)

2
src/AddIns/Misc/Profiler/Controller/Data/Linq/QueryAst.cs

@ -106,7 +106,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
BuildSql(b, new SqlQueryContext(provider)); BuildSql(b, new SqlQueryContext(provider));
Console.WriteLine(b.ToString()); Console.WriteLine(b.ToString());
return provider.RunSQL(b.ToString()).AsQueryable(); return provider.RunSQLNodeList(b.ToString()).AsQueryable();
} }
} }

16
src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs

@ -45,6 +45,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
Valid expressions in QueryAst nodes: Valid expressions in QueryAst nodes:
Only a limited set of expressions are valid in conditions and sort descriptors. Only a limited set of expressions are valid in conditions and sort descriptors.
These are checked by the SafeExpressionImporter. These are checked by the SafeExpressionImporter.
The set of valid expressions is:
- Integer constants - Integer constants
- Binary operators: < <= > >= == != && || - Binary operators: < <= > >= == != && ||
- value(List<int>).Contains(validExpr) - value(List<int>).Contains(validExpr)
@ -61,6 +62,8 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
Properties serving as query roots: Properties serving as query roots:
sqliteCallTreeNode.Children sqliteCallTreeNode.Children
-> AllCalls.Filter((SingleCall c) => sqliteCallTreeNode.ids.Contains(c.ParentID)) -> AllCalls.Filter((SingleCall c) => sqliteCallTreeNode.ids.Contains(c.ParentID))
sqliteCallTreeNode.Callers
-> AllCalls.Filter((SingleCall c) => idList.Contains(c.ID)) where idList is calculated using a manual SQL query
profilingDataSQLiteProvider.GetFunctions profilingDataSQLiteProvider.GetFunctions
-> AllCalls.Filter((SingleCall c) => @start <= c.DataSetId && c.DataSetId <= @end).MergeByName() -> AllCalls.Filter((SingleCall c) => @start <= c.DataSetId && c.DataSetId <= @end).MergeByName()
profilingDataSQLiteProvider.GetRoot profilingDataSQLiteProvider.GetRoot
@ -88,6 +91,7 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
x.Filter(y).Filter(z) -> x.Filter(y && z) x.Filter(y).Filter(z) -> x.Filter(y && z)
x.MergeByName().Filter(criteria) -> x.Filter(x, criteria).MergeByName() for some safe criterias x.MergeByName().Filter(criteria) -> x.Filter(x, criteria).MergeByName() for some safe criterias
Criterias are safe if they access no CallTreeNode properties except for NameMapping Criterias are safe if they access no CallTreeNode properties except for NameMapping
x.MergeByName().MergeByName() -> x.MergeByName()
SQL string building and execution: SQL string building and execution:
It must be possible to create SQL for every combination of QueryNodes, even if they do strange things like merging multiple times. It must be possible to create SQL for every combination of QueryNodes, even if they do strange things like merging multiple times.
@ -131,9 +135,17 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
get { return sqliteProvider.ProcessorFrequency; } get { return sqliteProvider.ProcessorFrequency; }
} }
internal IList<CallTreeNode> RunSQL(string command) public IList<CallTreeNode> RunSQLNodeList(string command)
{ {
return sqliteProvider.RunSQL(this, command); return sqliteProvider.RunSQLNodeList(this, command);
}
/// <summary>
/// Executes an SQL command that returns a list of integers.
/// </summary>
public List<int> RunSQLIDList(string command)
{
return sqliteProvider.RunSQLIDList(command);
} }
public IQueryable<CallTreeNode> CreateQuery(QueryNode query) public IQueryable<CallTreeNode> CreateQuery(QueryNode query)

23
src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs

@ -299,9 +299,9 @@ namespace ICSharpCode.Profiler.Controller.Data
return c => startIndex <= c.DataSetID && c.DataSetID <= endIndex; return c => startIndex <= c.DataSetID && c.DataSetID <= endIndex;
} }
internal IList<CallTreeNode> RunSQL(SQLiteQueryProvider queryProvider, string command) internal IList<CallTreeNode> RunSQLNodeList(SQLiteQueryProvider queryProvider, string command)
{ {
IList<CallTreeNode> result = new List<CallTreeNode>(); List<CallTreeNode> result = new List<CallTreeNode>();
SQLiteCommand cmd; SQLiteCommand cmd;
using (LockAndCreateCommand(out cmd)) { using (LockAndCreateCommand(out cmd)) {
@ -329,6 +329,25 @@ namespace ICSharpCode.Profiler.Controller.Data
return result; return result;
} }
/// <summary>
/// Executes an SQL command that returns a list of integers.
/// </summary>
internal List<int> RunSQLIDList(string command)
{
List<int> result = new List<int>();
SQLiteCommand cmd;
using (LockAndCreateCommand(out cmd)) {
cmd.CommandText = command;
using (SQLiteDataReader reader = cmd.ExecuteReader()) {
while (reader.Read()) {
result.Add(reader.GetInt32(0));
}
}
}
return result;
}
LockObject LockAndCreateCommand(out SQLiteCommand cmd) LockObject LockAndCreateCommand(out SQLiteCommand cmd)
{ {
this.rwLock.EnterReadLock(); this.rwLock.EnterReadLock();

1
src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteWriter.cs

@ -79,6 +79,7 @@ namespace ICSharpCode.Profiler.Controller.Data
/// <summary> /// <summary>
/// Sets or gets the processor frequency of the computer, where the profiling session was created. /// Sets or gets the processor frequency of the computer, where the profiling session was created.
/// The processor frequency is measured in MHz.
/// </summary> /// </summary>
public int ProcessorFrequency { public int ProcessorFrequency {
get { get {

9
src/AddIns/Misc/Profiler/Controller/Data/SQLiteCallTreeNode.cs

@ -133,6 +133,8 @@ namespace ICSharpCode.Profiler.Controller.Data
mergedNode.ids.AddRange(node.ids); mergedNode.ids.AddRange(node.ids);
mergedNode.callCount += node.callCount; mergedNode.callCount += node.callCount;
mergedNode.cpuCyclesSpent += node.cpuCyclesSpent; mergedNode.cpuCyclesSpent += node.cpuCyclesSpent;
mergedNode.activeCallCount += node.activeCallCount;
mergedNode.hasChildren |= node.hasChildren;
if (!initialised || mergedNode.nameId == node.nameId) if (!initialised || mergedNode.nameId == node.nameId)
mergedNode.nameId = node.nameId; mergedNode.nameId = node.nameId;
else else
@ -150,7 +152,12 @@ namespace ICSharpCode.Profiler.Controller.Data
if (this.parent != null) if (this.parent != null)
return (new CallTreeNode[] { this.parent }).AsQueryable(); return (new CallTreeNode[] { this.parent }).AsQueryable();
throw new NotImplementedException(); List<int> parentIDList = provider.RunSQLIDList(
"SELECT parentid FROM FunctionData "
+ "WHERE id IN(" + string.Join(",", this.ids.Select(s => s.ToString()).ToArray()) + @")");
Expression<Func<SingleCall, bool>> filterLambda = c => parentIDList.Contains(c.ID);
return provider.CreateQuery(new MergeByName(new Filter(AllCalls.Instance, filterLambda)));
} }
} }

2
src/AddIns/Misc/Profiler/Controller/Profiler.Controller.csproj

@ -143,7 +143,6 @@
<Compile Include="Profiler64.cs"> <Compile Include="Profiler64.cs">
<DependentUpon>Profiler.cs</DependentUpon> <DependentUpon>Profiler.cs</DependentUpon>
</Compile> </Compile>
<None Include="BuildEvents.proj" />
<CodeAnalysisDictionary Include="Properties\CodeAnalysisDictionary.xml" /> <CodeAnalysisDictionary Include="Properties\CodeAnalysisDictionary.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -162,7 +161,6 @@
<Folder Include="Data\Linq" /> <Folder Include="Data\Linq" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="BuildEvents.proj" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

2
src/AddIns/Misc/Profiler/Controller/Properties/AssemblyInfo.cs

@ -22,6 +22,8 @@ using System.Security.Permissions;
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("Profiler.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009DE118D0558F4B5301539B30DC7FF13F7034FCF5B0F6B581F826DA68B8FCF75962D82BBEA102F70D9EF67138002D99C78BC82DD276026682C93C96773D1BDB4B6D3B046ACEA1DF53FC15D7D8FF21453DAA82CAEBC44C25320F089ABA0EB7AFBE8E851C348AFEE329496918DFE6A122967ACD545612B37BD5F9CC5FD22DE95A99")]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("e0d1f9f9-0872-458d-ae91-7b6f0e073088")] [assembly: Guid("e0d1f9f9-0872-458d-ae91-7b6f0e073088")]

142
src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Data/CallTreeNodeStub.cs

@ -0,0 +1,142 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Linq;
using System.Collections.Generic;
using ICSharpCode.Profiler.Controller.Data;
namespace Profiler.Tests.Controller.Data
{
/// <summary>
/// Stub CallTreeNode for unit tests.
/// </summary>
public class CallTreeNodeStub : CallTreeNode
{
public override int GetHashCode()
{
throw new NotImplementedException();
}
public override bool Equals(CallTreeNode other)
{
throw new NotImplementedException();
}
public override System.Linq.IQueryable<CallTreeNode> Callers {
get {
throw new NotImplementedException();
}
}
public override CallTreeNode Merge(System.Collections.Generic.IEnumerable<CallTreeNode> nodes)
{
throw new NotImplementedException();
}
List<CallTreeNodeStub> children = new List<CallTreeNodeStub>();
CallTreeNode parent;
public override System.Linq.IQueryable<CallTreeNode> Children {
get {
return children.AsQueryable();
}
}
public sealed class ChildrenCollection : IEnumerable<CallTreeNodeStub>
{
CallTreeNodeStub parent;
public ChildrenCollection(CallTreeNodeStub parent)
{
this.parent = parent;
}
public void Add(CallTreeNodeStub node)
{
parent.AddChild(node);
}
public IEnumerator<CallTreeNodeStub> GetEnumerator()
{
return parent.children.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
public ChildrenCollection AddChildren {
get { return new ChildrenCollection(this); }
}
public void AddChild(CallTreeNodeStub node)
{
node.parent = this;
children.Add(node);
}
public override CallTreeNode Parent {
get {
return parent;
}
}
public override double TimeSpent {
get {
return CpuCyclesSpent;
}
}
public override double TimeSpentSelf {
get {
return CpuCyclesSpentSelf;
}
}
public long CpuCyclesSpentValue;
public override long CpuCyclesSpent {
get {
return CpuCyclesSpentValue;
}
}
public bool IsActiveAtStartValue;
public override bool IsActiveAtStart {
get {
return IsActiveAtStartValue;
}
}
public int RawCallCountValue;
public override int RawCallCount {
get {
return RawCallCountValue;
}
}
public NameMapping NameMappingValue;
public override NameMapping NameMapping {
get {
return NameMappingValue;
}
}
}
public class DataSetStub : IProfilingDataSet
{
public double CpuUsage { get; set; }
public bool IsFirst { get; set; }
public CallTreeNode RootNode { get; set; }
}
}

83
src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Data/LinqTests.cs

@ -0,0 +1,83 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using System.Collections.Generic;
using ICSharpCode.Profiler.Controller.Data;
using ICSharpCode.Profiler.Controller.Data.Linq;
using NUnit.Framework;
namespace Profiler.Tests.Controller.Data
{
[TestFixture]
public class LinqTests
{
const int k = 1000;
ProfilingDataSQLiteProvider provider;
[TestFixtureSetUp]
public void FixtureSetUp()
{
if (File.Exists("temp.sdps"))
File.Delete("temp.sdps");
NameMapping method1 = new NameMapping(1, "r1", "m1", new List<string>());
NameMapping method2 = new NameMapping(2, "r2", "m2", new List<string>());
NameMapping method3 = new NameMapping(3, "r3", "m3", new List<string>());
using (var writer = new ProfilingDataSQLiteWriter("temp.sdps", false, null)) {
writer.ProcessorFrequency = 2000; // MHz
writer.WriteMappings(new[] { method1, method2, method3 } );
CallTreeNodeStub dataSet;
dataSet = new CallTreeNodeStub {
NameMappingValue = method1,
AddChildren = {
new CallTreeNodeStub {
NameMappingValue = method2,
RawCallCountValue = 10,
CpuCyclesSpentValue = 500 * k
}
}
};
writer.WriteDataSet(new DataSetStub { CpuUsage = 0.3, IsFirst = true, RootNode = dataSet });
dataSet = new CallTreeNodeStub {
NameMappingValue = method1,
IsActiveAtStartValue = true,
AddChildren = {
new CallTreeNodeStub {
NameMappingValue = method2,
RawCallCountValue = 0,
IsActiveAtStartValue = true,
CpuCyclesSpentValue = 200 * k
},
new CallTreeNodeStub {
NameMappingValue = method3,
RawCallCountValue = 1,
IsActiveAtStartValue = true,
CpuCyclesSpentValue = 300 * k
}
}
};
writer.WriteDataSet(new DataSetStub { CpuUsage = 0.4, IsFirst = false, RootNode = dataSet });
}
provider = new ProfilingDataSQLiteProvider("test.sdps");
}
[TestFixtureTearDown]
public void FixtureCleanUp()
{
provider.Dispose();
File.Delete("temp.sdps");
}
[Test]
public void TestMethod()
{
// TODO: Add your test.
}
}
}

2
src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Data/MetadataTests.cs

@ -12,6 +12,7 @@ using System.Runtime.InteropServices;
namespace Profiler.Tests.Controller.Data namespace Profiler.Tests.Controller.Data
{ {
/*
[TestFixture] [TestFixture]
public class MetadataTests public class MetadataTests
{ {
@ -20,4 +21,5 @@ namespace Profiler.Tests.Controller.Data
} }
} }
*/
} }

2
src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Controller/Queries/NodePathTests.cs

@ -10,9 +10,11 @@ using NUnit.Framework;
namespace Profiler.Tests.Controller.Queries namespace Profiler.Tests.Controller.Queries
{ {
/*
[TestFixture] [TestFixture]
public class NodePathTests public class NodePathTests
{ {
} }
*/
} }

20
src/AddIns/Misc/Profiler/Tests/Profiler.Tests/Profiler.Tests.csproj

@ -6,7 +6,7 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>Profiler.Tests</RootNamespace> <RootNamespace>Profiler.Tests</RootNamespace>
<AssemblyName>Profiler.Tests</AssemblyName> <AssemblyName>Profiler.Tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> <SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -32,9 +32,13 @@
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<OutputPath>..\..\..\..\..\..\bin\UnitTests\</OutputPath>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\Controller\ICSharpCode.Profiler.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\bin\</OutputPath>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType> <DebugType>Full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
@ -42,7 +46,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols> <DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType> <DebugType>None</DebugType>
<Optimize>True</Optimize> <Optimize>True</Optimize>
@ -62,6 +65,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup> <ItemGroup>
<Reference Include="nunit.framework"> <Reference Include="nunit.framework">
@ -77,8 +87,10 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controller\Data\LinqTests.cs" />
<Compile Include="Controller\Data\MetadataTests.cs" /> <Compile Include="Controller\Data\MetadataTests.cs" />
<Compile Include="Controller\Data\SQLiteTests.cs" /> <Compile Include="Controller\Data\SQLiteTests.cs" />
<Compile Include="Controller\Data\CallTreeNodeStub.cs" />
<Compile Include="Controller\Queries\NodePathTests.cs" /> <Compile Include="Controller\Queries\NodePathTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
@ -98,7 +110,7 @@
<ProjectReference Include="..\..\Controller\Profiler.Controller.csproj"> <ProjectReference Include="..\..\Controller\Profiler.Controller.csproj">
<Project>{72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F}</Project> <Project>{72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F}</Project>
<Name>Profiler.Controller</Name> <Name>Profiler.Controller</Name>
<Private>False</Private> <Private>True</Private>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
</Project> </Project>

16
src/Main/Core/Project/Src/Services/MessageService/MessageService.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.Core
/// <see cref="StringParser"/>, /// <see cref="StringParser"/>,
/// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments. /// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments.
/// </summary> /// </summary>
public static void ShowErrorFormatted(string formatstring, params string[] formatitems) public static void ShowErrorFormatted(string formatstring, params object[] formatitems)
{ {
ShowError(Format(formatstring, formatitems)); ShowError(Format(formatstring, formatitems));
} }
@ -71,7 +71,7 @@ namespace ICSharpCode.Core
/// <see cref="StringParser"/>, /// <see cref="StringParser"/>,
/// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments. /// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments.
/// </summary> /// </summary>
public static void ShowWarningFormatted(string formatstring, params string[] formatitems) public static void ShowWarningFormatted(string formatstring, params object[] formatitems)
{ {
ShowWarning(Format(formatstring, formatitems)); ShowWarning(Format(formatstring, formatitems));
} }
@ -85,12 +85,12 @@ namespace ICSharpCode.Core
return ServiceManager.Instance.MessageService.AskQuestion(question, caption); return ServiceManager.Instance.MessageService.AskQuestion(question, caption);
} }
public static bool AskQuestionFormatted(string caption, string formatstring, params string[] formatitems) public static bool AskQuestionFormatted(string caption, string formatstring, params object[] formatitems)
{ {
return AskQuestion(Format(formatstring, formatitems), caption); return AskQuestion(Format(formatstring, formatitems), caption);
} }
public static bool AskQuestionFormatted(string formatstring, params string[] formatitems) public static bool AskQuestionFormatted(string formatstring, params object[] formatitems)
{ {
return AskQuestion(Format(formatstring, formatitems)); return AskQuestion(Format(formatstring, formatitems));
} }
@ -167,12 +167,12 @@ namespace ICSharpCode.Core
ShowMessage(message, DefaultMessageBoxTitle); ShowMessage(message, DefaultMessageBoxTitle);
} }
public static void ShowMessageFormatted(string formatstring, params string[] formatitems) public static void ShowMessageFormatted(string formatstring, params object[] formatitems)
{ {
ShowMessage(Format(formatstring, formatitems)); ShowMessage(Format(formatstring, formatitems));
} }
public static void ShowMessageFormatted(string caption, string formatstring, params string[] formatitems) public static void ShowMessageFormatted(string caption, string formatstring, params object[] formatitems)
{ {
ShowMessage(Format(formatstring, formatitems), caption); ShowMessage(Format(formatstring, formatitems), caption);
} }
@ -183,7 +183,7 @@ namespace ICSharpCode.Core
ServiceManager.Instance.MessageService.ShowMessage(message, caption); ServiceManager.Instance.MessageService.ShowMessage(message, caption);
} }
static string Format(string formatstring, string[] formatitems) static string Format(string formatstring, object[] formatitems)
{ {
try { try {
return String.Format(StringParser.Parse(formatstring), formatitems); return String.Format(StringParser.Parse(formatstring), formatitems);
@ -191,7 +191,7 @@ namespace ICSharpCode.Core
LoggingService.Warn(ex); LoggingService.Warn(ex);
StringBuilder b = new StringBuilder(StringParser.Parse(formatstring)); StringBuilder b = new StringBuilder(StringParser.Parse(formatstring));
foreach(string formatitem in formatitems) { foreach(object formatitem in formatitems) {
b.Append("\nItem: "); b.Append("\nItem: ");
b.Append(formatitem); b.Append(formatitem);
} }

Loading…
Cancel
Save