You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
3.7 KiB
153 lines
3.7 KiB
// <file> |
|
// <copyright see="prj:///doc/copyright.txt"/> |
|
// <license see="prj:///doc/license.txt"/> |
|
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/> |
|
// <version>$Revision$</version> |
|
// </file> |
|
|
|
using System; |
|
using System.Collections.Generic; |
|
using System.Collections.ObjectModel; |
|
using System.Linq; |
|
|
|
namespace ICSharpCode.Profiler.Controller.Data |
|
{ |
|
/// <summary> |
|
/// Describes a CallTreeNode which allows direct access to the shared memory of an existing Profiler. It depends on an existing Profiler. |
|
/// </summary> |
|
sealed unsafe class UnmanagedCallTreeNode32 : CallTreeNode |
|
{ |
|
FunctionInfo *data; |
|
CallTreeNode parent; |
|
const ulong CpuCycleMask = 0x007fffffffffffffL; |
|
UnmanagedProfilingDataSet dataSet; |
|
|
|
internal UnmanagedCallTreeNode32(UnmanagedProfilingDataSet dataSet, FunctionInfo *data, CallTreeNode parent) |
|
{ |
|
this.data = data; |
|
this.dataSet = dataSet; |
|
this.parent = parent; |
|
} |
|
|
|
public override System.Linq.IQueryable<CallTreeNode> Children { |
|
get { |
|
dataSet.VerifyAccess(); |
|
|
|
List<UnmanagedCallTreeNode32> children = new List<UnmanagedCallTreeNode32>(); |
|
|
|
TargetProcessPointer32* childrenPtr = FunctionInfo.GetChildren32(data); |
|
for (int i = 0; i <= data->LastChildIndex; i++) |
|
{ |
|
FunctionInfo* child = dataSet.GetFunctionInfo(childrenPtr[i]); |
|
if (child != null) |
|
children.Add(new UnmanagedCallTreeNode32(dataSet, child, this)); |
|
} |
|
|
|
children.Sort((a,b) => a.Index.CompareTo(b.Index)); |
|
|
|
return children.AsQueryable(); |
|
} |
|
} |
|
|
|
public override NameMapping NameMapping { |
|
get { |
|
return this.dataSet.GetMapping(this.data->Id); |
|
} |
|
} |
|
|
|
public override int RawCallCount { |
|
get { |
|
dataSet.VerifyAccess(); // need to verify before deferencing data |
|
return this.data->CallCount; |
|
} |
|
} |
|
|
|
public int Index { |
|
get { |
|
dataSet.VerifyAccess(); // need to verify before deferencing data |
|
return (int)(this.data->TimeSpent >> 56); |
|
} |
|
} |
|
|
|
public override bool IsActiveAtStart { |
|
get { |
|
dataSet.VerifyAccess(); // need to verify before deferencing data |
|
return (this.data->TimeSpent & ((ulong)1 << 55)) != 0; |
|
} |
|
} |
|
|
|
public override long CpuCyclesSpent { |
|
get { |
|
dataSet.VerifyAccess(); // need to verify before deferencing data |
|
return (long)(this.data->TimeSpent & CpuCycleMask); |
|
} |
|
} |
|
|
|
public override long CpuCyclesSpentSelf { |
|
get { |
|
dataSet.VerifyAccess(); |
|
|
|
long result = (long)(this.data->TimeSpent & CpuCycleMask); |
|
|
|
TargetProcessPointer32* childrenPtr = FunctionInfo.GetChildren32(data); |
|
for (int i = 0; i <= data->LastChildIndex; i++) |
|
{ |
|
FunctionInfo* child = dataSet.GetFunctionInfo(childrenPtr[i]); |
|
if (child != null) |
|
result -= (long)(child->TimeSpent & CpuCycleMask); |
|
} |
|
|
|
return result; |
|
} |
|
} |
|
|
|
public override CallTreeNode Parent { |
|
get { |
|
return this.parent; |
|
} |
|
} |
|
|
|
public override double TimeSpent { |
|
get { |
|
return this.CpuCyclesSpent / (1000.0 * this.dataSet.ProcessorFrequency); |
|
} |
|
} |
|
|
|
public override double TimeSpentSelf { |
|
get { |
|
return this.CpuCyclesSpentSelf / (1000.0 * this.dataSet.ProcessorFrequency); |
|
} |
|
} |
|
|
|
public override CallTreeNode Merge(IEnumerable<CallTreeNode> nodes) |
|
{ |
|
throw new NotImplementedException(); |
|
} |
|
|
|
public override IQueryable<CallTreeNode> Callers { |
|
get { |
|
return GetCallers().AsQueryable(); |
|
} |
|
} |
|
|
|
IEnumerable<CallTreeNode> GetCallers() |
|
{ |
|
if (parent != null) yield return parent; |
|
} |
|
|
|
public override bool Equals(CallTreeNode other) |
|
{ |
|
UnmanagedCallTreeNode32 node = other as UnmanagedCallTreeNode32; |
|
if (node != null) { |
|
return node.data == this.data; |
|
} |
|
|
|
return false; |
|
} |
|
|
|
public override int GetHashCode() |
|
{ |
|
return (new IntPtr(data)).GetHashCode(); |
|
} |
|
} |
|
}
|
|
|