void InsertTree(SQLiteCommand cmd, CallTreeNode node, int parentId, IProfilingDataSet dataSet, FunctionDataParams dataParams) { int thisID = functionInfoCount++; foreach (CallTreeNode child in node.Children) { InsertTree(cmd, child, thisID, dataSet, dataParams); } // we sometimes saw invalid data with the 0x0080000000000000L bit set if (node.CpuCyclesSpent > 0x0007ffffffffffffL || node.CpuCyclesSpent < 0) { throw new InvalidOperationException("Too large CpuCyclesSpent - there's something wrong in the data"); } dataParams.callCount.Value = node.RawCallCount; dataParams.isActiveAtStart.Value = node.IsActiveAtStart; dataParams.cpuCyclesSpent.Value = node.CpuCyclesSpent; dataParams.dataSetId.Value = dataSetCount; dataParams.functionInfoId.Value = thisID; dataParams.nameId.Value = node.NameMapping.Id; dataParams.parentId.Value = parentId; dataParams.endId.Value = functionInfoCount - 1; cmd.ExecuteNonQuery(); }
/// <summary> /// Writes a profiling dataset to the database. /// </summary> public void WriteDataSet(IProfilingDataSet dataSet) { if (dataSet == null) { throw new ArgumentNullException("dataSet"); } using (SQLiteTransaction transaction = this.connection.BeginTransaction()) { SQLiteCommand cmd = this.connection.CreateCommand(); if (dataSetCount == -1) { dataSetCount = 0; } cmd.Parameters.Add(new SQLiteParameter("id", dataSetCount)); cmd.Parameters.Add(new SQLiteParameter("isfirst", dataSet.IsFirst)); cmd.Parameters.Add(new SQLiteParameter("rootid", functionInfoCount)); cmd.CommandText = "INSERT INTO DataSets(id, isfirst, rootid)" + "VALUES(?,?,?);"; int dataSetStartId = functionInfoCount; using (SQLiteCommand loopCommand = this.connection.CreateCommand()) { CallTreeNode node = dataSet.RootNode; loopCommand.CommandText = "INSERT INTO Calls(id, endid, parentid, nameid, cpucyclesspent, cpucyclesspentself, isactiveatstart, callcount)" + "VALUES(?,?,?,?,?,?,?,?);"; CallsParams dataParams = new CallsParams(); loopCommand.Parameters.Add(dataParams.functionInfoId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.endId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.parentId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.nameId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.cpuCyclesSpent = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.cpuCyclesSpentSelf = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.isActiveAtStart = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.callCount = new SQLiteParameter()); InsertCalls(loopCommand, node, -1, dataParams); } using (SQLiteCommand functionsCommand = this.connection.CreateCommand()) { functionsCommand.CommandText = string.Format(@" INSERT INTO Functions SELECT {0}, nameid, SUM(cpucyclesspent), SUM(cpucyclesspentself), SUM(isactiveatstart), SUM(callcount), MAX(id != endid) FROM Calls WHERE id BETWEEN {1} AND {2} GROUP BY nameid;" , dataSetCount, dataSetStartId, functionInfoCount - 1); functionsCommand.ExecuteNonQuery(); } cmd.ExecuteNonQuery(); dataSetCount++; transaction.Commit(); } }
/// <summary> /// Writes a profiling dataset to the database. /// </summary> public void WriteDataSet(IProfilingDataSet dataSet) { if (dataSet == null) { throw new ArgumentNullException("dataSet"); } using (SQLiteTransaction transaction = this.connection.BeginTransaction()) { SQLiteCommand cmd = this.connection.CreateCommand(); if (dataSetCount == -1) { dataSetCount = 0; } cmd.Parameters.Add(new SQLiteParameter("id", dataSetCount)); cmd.Parameters.Add(new SQLiteParameter("cpuuage", dataSet.CpuUsage.ToString(CultureInfo.InvariantCulture))); cmd.Parameters.Add(new SQLiteParameter("isfirst", dataSet.IsFirst)); cmd.Parameters.Add(new SQLiteParameter("rootid", functionInfoCount)); cmd.CommandText = "INSERT INTO DataSets(id, cpuusage, isfirst, rootid)" + "VALUES(?,?,?,?);"; using (SQLiteCommand loopCommand = this.connection.CreateCommand()) { CallTreeNode node = dataSet.RootNode; loopCommand.CommandText = "INSERT INTO FunctionData(datasetid, id, endid, parentid, nameid, timespent, isactiveatstart, callcount)" + "VALUES(?,?,?,?,?,?,?,?);"; FunctionDataParams dataParams = new FunctionDataParams(); loopCommand.Parameters.Add(dataParams.dataSetId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.functionInfoId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.endId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.parentId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.nameId = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.cpuCyclesSpent = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.isActiveAtStart = new SQLiteParameter()); loopCommand.Parameters.Add(dataParams.callCount = new SQLiteParameter()); bool addedData = true; if (profileUnitTests) { addedData = FindUnitTestsAndInsert(loopCommand, node, dataSet, dataParams); } else { InsertTree(loopCommand, node, -1, dataSet, dataParams); } if (addedData) { cmd.ExecuteNonQuery(); dataSetCount++; } } transaction.Commit(); } }
public override bool Equals(CallTreeNode other) { SQLiteCallTreeNode node = other as SQLiteCallTreeNode; if (node != null) { int[] a = this.IdList; int[] b = node.IdList; if (a.Length != b.Length) { return(false); } for (int i = 0; i < a.Length; i++) { if (a[i] != b[i]) { return(false); } } return(true); } return(false); }
void InsertCalls(SQLiteCommand cmd, CallTreeNode node, int parentId, CallsParams dataParams) { int thisID = functionInfoCount++; foreach (CallTreeNode child in node.Children) { InsertCalls(cmd, child, thisID, dataParams); } long cpuCycles = node.CpuCyclesSpent; long cpuCyclesSelf = node.CpuCyclesSpentSelf; // we sometimes saw invalid data with the 0x0080000000000000L bit set if (cpuCycles > 0x0007ffffffffffffL || cpuCycles < 0) { throw new InvalidOperationException("Too large CpuCyclesSpent - there's something wrong in the data"); } if (node.NameMapping.Id != 0 && (cpuCyclesSelf > cpuCycles || cpuCyclesSelf < 0)) { throw new InvalidOperationException("Too large/small CpuCyclesSpentSelf (" + cpuCyclesSelf + ") - there's something wrong in the data"); } dataParams.callCount.Value = node.RawCallCount; dataParams.isActiveAtStart.Value = node.IsActiveAtStart; dataParams.cpuCyclesSpent.Value = cpuCycles; dataParams.cpuCyclesSpentSelf.Value = cpuCyclesSelf; dataParams.functionInfoId.Value = thisID; dataParams.nameId.Value = node.NameMapping.Id; dataParams.parentId.Value = parentId; dataParams.endId.Value = functionInfoCount - 1; cmd.ExecuteNonQuery(); }
public override bool Equals(CallTreeNode other) { if (other is UnmanagedCallTreeNode64) { UnmanagedCallTreeNode64 node = other as UnmanagedCallTreeNode64; return(node.data == this.data); } return(false); }
public override bool Equals(CallTreeNode other) { UnmanagedCallTreeNode64 node = other as UnmanagedCallTreeNode64; if (node != null) { return(node.data == data); } return(false); }
/// <inheritdoc/> public override bool Equals(CallTreeNode other) { UnitTestRootCallTreeNode node = other as UnitTestRootCallTreeNode; if (node != null && unitTests != null) { return(node.unitTests.SequenceEqual(unitTests)); } return(false); }
void FindUnitTests(CallTreeNode parentNode, IList <CallTreeNode> list) { if (IsUnitTest(parentNode.NameMapping)) { list.Add(parentNode); return; } foreach (var node in parentNode.Children) { FindUnitTests(node, list); } }
bool FindUnitTestsAndInsert(SQLiteCommand cmd, CallTreeNode node, IProfilingDataSet dataSet, FunctionDataParams dataParams) { List <CallTreeNode> list = new List <CallTreeNode>(); FindUnitTests(node, list); if (list.Count > 0) { InsertTree(cmd, new UnitTestRootCallTreeNode(list), -1, dataSet, dataParams); return(true); } return(false); }
public override bool Equals(CallTreeNode other) { if (other is SQLiteCallTreeNode) { SQLiteCallTreeNode node = other as SQLiteCallTreeNode; if (node.ids.Count != this.ids.Count) { return(false); } for (int i = 0; i < this.ids.Count; i++) { if (node.ids[i] != this.ids[i]) { return(false); } } return(true); } return(false); }
internal UnmanagedCallTreeNode64(UnmanagedProfilingDataSet dataSet, FunctionInfo *data, CallTreeNode parent) { this.data = data; this.dataSet = dataSet; this.parent = parent; }
public UnitTestDataSet(CallTreeNode root, bool isFirst) { this.RootNode = root; this.IsFirst = isFirst; }
/// <summary> /// Creates a new CallTreeNode. /// </summary> public SQLiteCallTreeNode(int nameId, CallTreeNode parent, SQLiteQueryProvider provider) { this.nameId = nameId; this.parent = parent; this.provider = provider; }
/// <summary> /// Creates a new CallTreeNode. /// </summary> public SQLiteCallTreeNode(int nameId, CallTreeNode parent, ProfilingDataSQLiteProvider provider) { this.nameId = nameId; this.parent = parent; this.provider = provider; }
/// <inheritdoc/> public override bool Equals(CallTreeNode other) { return((other is UnitTestRootCallTreeNode) && (other as UnitTestRootCallTreeNode).unitTests.SequenceEqual(unitTests)); }