|
|
|
|
@ -7,6 +7,7 @@
@@ -7,6 +7,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using ICSharpCode.Profiler.Controller.Data; |
|
|
|
|
@ -26,18 +27,18 @@ namespace Profiler.Tests.Controller.Data
@@ -26,18 +27,18 @@ namespace Profiler.Tests.Controller.Data
|
|
|
|
|
{ |
|
|
|
|
if (File.Exists("temp.sdps")) |
|
|
|
|
File.Delete("temp.sdps"); |
|
|
|
|
NameMapping method0 = new NameMapping(0, "r0", "m0", new List<string>()); |
|
|
|
|
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 } ); |
|
|
|
|
writer.WriteMappings(new[] { method0, method1, method2 } ); |
|
|
|
|
CallTreeNodeStub dataSet; |
|
|
|
|
dataSet = new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method1, |
|
|
|
|
NameMappingValue = method0, |
|
|
|
|
AddChildren = { |
|
|
|
|
new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method2, |
|
|
|
|
NameMappingValue = method1, |
|
|
|
|
RawCallCountValue = 10, |
|
|
|
|
CpuCyclesSpentValue = 500 * k |
|
|
|
|
} |
|
|
|
|
@ -45,26 +46,46 @@ namespace Profiler.Tests.Controller.Data
@@ -45,26 +46,46 @@ namespace Profiler.Tests.Controller.Data
|
|
|
|
|
}; |
|
|
|
|
writer.WriteDataSet(new DataSetStub { CpuUsage = 0.3, IsFirst = true, RootNode = dataSet }); |
|
|
|
|
dataSet = new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method1, |
|
|
|
|
NameMappingValue = method0, |
|
|
|
|
IsActiveAtStartValue = true, |
|
|
|
|
AddChildren = { |
|
|
|
|
new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method2, |
|
|
|
|
NameMappingValue = method1, |
|
|
|
|
RawCallCountValue = 0, |
|
|
|
|
IsActiveAtStartValue = true, |
|
|
|
|
CpuCyclesSpentValue = 200 * k |
|
|
|
|
}, |
|
|
|
|
new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method3, |
|
|
|
|
NameMappingValue = method2, |
|
|
|
|
RawCallCountValue = 1, |
|
|
|
|
IsActiveAtStartValue = true, |
|
|
|
|
CpuCyclesSpentValue = 300 * k |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
writer.WriteDataSet(new DataSetStub { CpuUsage = 0.4, IsFirst = false, RootNode = dataSet }); |
|
|
|
|
dataSet = new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method0, |
|
|
|
|
IsActiveAtStartValue = true, |
|
|
|
|
AddChildren = { |
|
|
|
|
new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method2, |
|
|
|
|
RawCallCountValue = 0, |
|
|
|
|
IsActiveAtStartValue = true, |
|
|
|
|
CpuCyclesSpentValue = 50 * k, |
|
|
|
|
AddChildren = { |
|
|
|
|
new CallTreeNodeStub { |
|
|
|
|
NameMappingValue = method1, |
|
|
|
|
RawCallCountValue = 5, |
|
|
|
|
CpuCyclesSpentValue = 1 * k |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
writer.WriteDataSet(new DataSetStub { CpuUsage = 0.1, IsFirst = false, RootNode = dataSet }); |
|
|
|
|
writer.Close(); |
|
|
|
|
} |
|
|
|
|
provider = new ProfilingDataSQLiteProvider("test.sdps"); |
|
|
|
|
provider = new ProfilingDataSQLiteProvider("temp.sdps"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[TestFixtureTearDown] |
|
|
|
|
@ -75,9 +96,51 @@ namespace Profiler.Tests.Controller.Data
@@ -75,9 +96,51 @@ namespace Profiler.Tests.Controller.Data
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestMethod() |
|
|
|
|
public void TestDataSets() |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(3, provider.DataSets.Count); |
|
|
|
|
Assert.AreEqual(0.3, provider.DataSets[0].CpuUsage); |
|
|
|
|
Assert.AreEqual(0.4, provider.DataSets[1].CpuUsage); |
|
|
|
|
Assert.AreEqual(0.1, provider.DataSets[2].CpuUsage); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(provider.DataSets[0].IsFirst); |
|
|
|
|
Assert.IsFalse(provider.DataSets[1].IsFirst); |
|
|
|
|
Assert.IsFalse(provider.DataSets[2].IsFirst); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestMergedTree() |
|
|
|
|
{ |
|
|
|
|
CallTreeNode root = provider.GetRoot(0, 1); |
|
|
|
|
Assert.IsTrue(root.HasChildren); |
|
|
|
|
CallTreeNode[] children = root.Children.ToArray(); |
|
|
|
|
Assert.AreEqual(2, children.Length); |
|
|
|
|
Assert.IsFalse(children[0].HasChildren); |
|
|
|
|
Assert.AreEqual("m1", children[0].Name); |
|
|
|
|
Assert.AreEqual(10, children[0].CallCount); |
|
|
|
|
Assert.AreEqual(700 * k, children[0].CpuCyclesSpent); |
|
|
|
|
|
|
|
|
|
Assert.IsFalse(children[1].HasChildren); |
|
|
|
|
Assert.AreEqual("m2", children[1].Name); |
|
|
|
|
Assert.AreEqual(1, children[1].CallCount); |
|
|
|
|
Assert.AreEqual(300 * k, children[1].CpuCyclesSpent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestFunctions() |
|
|
|
|
{ |
|
|
|
|
// TODO: Add your test.
|
|
|
|
|
CallTreeNode[] functions = provider.GetFunctions(1, 2).OrderBy(f => f.Name).ToArray(); |
|
|
|
|
Assert.AreEqual(2, functions.Length); |
|
|
|
|
|
|
|
|
|
Assert.AreEqual("m1", functions[0].Name); |
|
|
|
|
Assert.IsFalse(functions[0].HasChildren); |
|
|
|
|
Assert.AreEqual(6, functions[0].CallCount); |
|
|
|
|
Assert.AreEqual(201 * k, functions[0].CpuCyclesSpent); |
|
|
|
|
|
|
|
|
|
Assert.AreEqual("m2", functions[1].Name); |
|
|
|
|
Assert.IsTrue(functions[1].HasChildren); |
|
|
|
|
Assert.AreEqual(1, functions[1].CallCount); |
|
|
|
|
Assert.AreEqual(350 * k, functions[1].CpuCyclesSpent); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|