X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/4e4e5a6f2694187498445a6ac6f1634ce8141119..2d39b0e377c0896910ee49ae70082ba665faf986:/profiler/Profile.cpp diff --git a/profiler/Profile.cpp b/profiler/Profile.cpp index 126e6f6..b5e0224 100644 --- a/profiler/Profile.cpp +++ b/profiler/Profile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2008, 2014 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,22 +27,23 @@ #include "Profile.h" #include "ProfileNode.h" -#include +#include namespace JSC { -PassRefPtr Profile::create(const UString& title, unsigned uid) +PassRefPtr Profile::create(const String& title, unsigned uid) { return adoptRef(new Profile(title, uid)); } -Profile::Profile(const UString& title, unsigned uid) +Profile::Profile(const String& title, unsigned uid) : m_title(title) , m_uid(uid) + , m_idleTime(0) { // FIXME: When multi-threading is supported this will be a vector and calls // into the profiler will need to know which thread it is executing on. - m_head = ProfileNode::create(CallIdentifier("Thread_1", UString(), 0), 0, 0); + m_head = ProfileNode::create(0, CallIdentifier("Thread_1", String(), 0, 0), 0, 0); } Profile::~Profile() @@ -65,52 +66,18 @@ void Profile::forEach(void (ProfileNode::*function)()) } } -void Profile::focus(const ProfileNode* profileNode) -{ - if (!profileNode || !m_head) - return; - - bool processChildren; - const CallIdentifier& callIdentifier = profileNode->callIdentifier(); - for (ProfileNode* currentNode = m_head.get(); currentNode; currentNode = currentNode->traverseNextNodePreOrder(processChildren)) - processChildren = currentNode->focus(callIdentifier); - - // Set the visible time of all nodes so that the %s display correctly. - forEach(&ProfileNode::calculateVisibleTotalTime); -} - -void Profile::exclude(const ProfileNode* profileNode) -{ - if (!profileNode || !m_head) - return; - - const CallIdentifier& callIdentifier = profileNode->callIdentifier(); - - for (ProfileNode* currentNode = m_head.get(); currentNode; currentNode = currentNode->traverseNextNodePreOrder()) - currentNode->exclude(callIdentifier); - - // Set the visible time of the head so the %s display correctly. - m_head->setVisibleTotalTime(m_head->totalTime() - m_head->selfTime()); - m_head->setVisibleSelfTime(0.0); -} - -void Profile::restoreAll() -{ - forEach(&ProfileNode::restore); -} - #ifndef NDEBUG void Profile::debugPrintData() const { - printf("Call graph:\n"); + dataLogF("Call graph:\n"); m_head->debugPrintData(0); } -typedef pair NameCountPair; +typedef WTF::KeyValuePair NameCountPair; static inline bool functionNameCountPairComparator(const NameCountPair& a, const NameCountPair& b) { - return a.second > b.second; + return a.value > b.value; } void Profile::debugPrintDataSampleStyle() const @@ -118,18 +85,18 @@ void Profile::debugPrintDataSampleStyle() const typedef Vector NameCountPairVector; FunctionCallHashCount countedFunctions; - printf("Call graph:\n"); + dataLogF("Call graph:\n"); m_head->debugPrintDataSampleStyle(0, countedFunctions); - printf("\nTotal number in stack:\n"); + 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) - printf(" %-12d%s\n", (*it).second, UString((*it).first).UTF8String().data()); + dataLogF(" %-12d%s\n", (*it).value, String((*it).key).utf8().data()); - printf("\nSort by top of stack, same collapsed (when >= 5):\n"); + dataLogF("\nSort by top of stack, same collapsed (when >= 5):\n"); } #endif