void Profile::debugPrintDataSampleStyle() const { typedef Vector<NameCountPair> NameCountPairVector; FunctionCallHashCount countedFunctions; dataLogF("Call graph:\n"); m_head->debugPrintDataSampleStyle(0, countedFunctions); dataLogF("\nTotal number in stack:\n"); NameCountPairVector sortedFunctions(countedFunctions.size()); copyToVector(countedFunctions, sortedFunctions); std::sort(sortedFunctions.begin(), sortedFunctions.end(), functionNameCountPairComparator); for (NameCountPairVector::iterator it = sortedFunctions.begin(); it != sortedFunctions.end(); ++it) dataLogF(" %-12d%s\n", (*it).value, String((*it).key).utf8().data()); dataLogF("\nSort by top of stack, same collapsed (when >= 5):\n"); }
void Profile::debugPrintDataSampleStyle() const { typedef Vector<NameCountPair> NameCountPairVector; FunctionCallHashCount countedFunctions; printf("Call graph:\n"); m_head->debugPrintDataSampleStyle(0, countedFunctions); printf("\nTotal number in stack:\n"); NameCountPairVector sortedFunctions(countedFunctions.size()); copyToVector(countedFunctions, sortedFunctions); #if PLATFORM(ANDROID) _sort(sortedFunctions.begin(), sortedFunctions.end(), functionNameCountPairComparator); #else std::sort(sortedFunctions.begin(), sortedFunctions.end(), functionNameCountPairComparator); #endif for (NameCountPairVector::iterator it = sortedFunctions.begin(); it != sortedFunctions.end(); ++it) printf(" %-12d%s\n", (*it).second, UString((*it).first).UTF8String().c_str()); printf("\nSort by top of stack, same collapsed (when >= 5):\n"); }
void Profile::debugPrintSampleStyle() { typedef Vector<NameCountPair> NameCountPairVector; CalculateProfileSubtreeDataFunctor functor; m_rootNode->forEachNodePostorder(functor); ProfileNode::ProfileSubtreeData data = functor.returnValue(); FunctionCallHashCount countedFunctions; dataLogF("Call graph:\n"); m_rootNode->debugPrintSampleStyleRecursively(0, countedFunctions, data); dataLogF("\nTotal number in stack:\n"); NameCountPairVector sortedFunctions(countedFunctions.size()); copyToVector(countedFunctions, sortedFunctions); std::sort(sortedFunctions.begin(), sortedFunctions.end(), functionNameCountPairComparator); for (NameCountPairVector::iterator it = sortedFunctions.begin(); it != sortedFunctions.end(); ++it) dataLogF(" %-12d%s\n", (*it).value, String((*it).key).utf8().data()); dataLogF("\nSort by top of stack, same collapsed (when >= 5):\n"); }
// print the profiled data in a format that matches the tool sample's output. double ProfileNode::debugPrintSampleStyleRecursively(int indentLevel, FunctionCallHashCount& countedFunctions, const ProfileSubtreeData& data) { dataLogF(" "); auto it = data.selfAndTotalTimes.find(this); ASSERT(it != data.selfAndTotalTimes.end()); double nodeTotalTime = it->value.second; // Print function names const char* name = functionName().utf8().data(); double sampleCount = nodeTotalTime * 1000; if (indentLevel) { for (int i = 0; i < indentLevel; ++i) dataLogF(" "); countedFunctions.add(functionName().impl()); dataLogF("%.0f %s\n", sampleCount ? sampleCount : 1, name); } else dataLogF("%s\n", name); ++indentLevel; // Print children's names and information double sumOfChildrensCount = 0.0; for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild) sumOfChildrensCount += (*currentChild)->debugPrintSampleStyleRecursively(indentLevel, countedFunctions, data); sumOfChildrensCount *= 1000; // // Print remainder of samples to match sample's output if (sumOfChildrensCount < sampleCount) { dataLogF(" "); while (indentLevel--) dataLogF(" "); dataLogF("%.0f %s\n", sampleCount - sumOfChildrensCount, functionName().utf8().data()); } return nodeTotalTime; }
// print the profiled data in a format that matches the tool sample's output. double ProfileNode::debugPrintDataSampleStyle(int indentLevel, FunctionCallHashCount& countedFunctions) const { dataLogF(" "); // Print function names const char* name = functionName().utf8().data(); double sampleCount = m_totalTime * 1000; if (indentLevel) { for (int i = 0; i < indentLevel; ++i) dataLogF(" "); countedFunctions.add(functionName().impl()); dataLogF("%.0f %s\n", sampleCount ? sampleCount : 1, name); } else dataLogF("%s\n", name); ++indentLevel; // Print children's names and information double sumOfChildrensCount = 0.0; for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild) sumOfChildrensCount += (*currentChild)->debugPrintDataSampleStyle(indentLevel, countedFunctions); sumOfChildrensCount *= 1000; // // Print remainder of samples to match sample's output if (sumOfChildrensCount < sampleCount) { dataLogF(" "); while (indentLevel--) dataLogF(" "); dataLogF("%.0f %s\n", sampleCount - sumOfChildrensCount, functionName().utf8().data()); } return m_totalTime; }