/**
- * CpuProfile contains a CPU profile in a form of two call trees:
- * - top-down (from main() down to functions that do all the work);
- * - bottom-up call graph (in backward direction).
+ * CpuProfile contains a CPU profile in a form of top-down call tree
+ * (from main() down to functions that do all the work).
*/
class V8EXPORT CpuProfile {
public:
/** Returns CPU profile title. */
Handle<String> GetTitle() const;
- /** Returns the root node of the bottom up call tree. */
- const CpuProfileNode* GetBottomUpRoot() const;
-
/** Returns the root node of the top down call tree. */
const CpuProfileNode* GetTopDownRoot() const;
}
-const CpuProfileNode* CpuProfile::GetBottomUpRoot() const {
- i::Isolate* isolate = i::Isolate::Current();
- IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot");
- const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
- return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root());
-}
-
-
const CpuProfileNode* CpuProfile::GetTopDownRoot() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot");
namespace v8 {
namespace internal {
-static const int kEventsBufferSize = 256 * KB;
static const int kTickSamplesBufferChunkSize = 64 * KB;
static const int kTickSamplesBufferChunksCount = 16;
static const int kProfilerStackSize = 64 * KB;
void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
top_down_.AddPathFromEnd(path);
- bottom_up_.AddPathFromStart(path);
}
void CpuProfile::CalculateTotalTicks() {
top_down_.CalculateTotalTicks();
- bottom_up_.CalculateTotalTicks();
}
void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) {
top_down_.SetTickRatePerMs(actual_sampling_rate);
- bottom_up_.SetTickRatePerMs(actual_sampling_rate);
}
ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken);
CpuProfile* clone = new CpuProfile(title_, uid_);
clone->top_down_.FilteredClone(&top_down_, security_token_id);
- clone->bottom_up_.FilteredClone(&bottom_up_, security_token_id);
return clone;
}
void CpuProfile::ShortPrint() {
OS::Print("top down ");
top_down_.ShortPrint();
- OS::Print("bottom up ");
- bottom_up_.ShortPrint();
}
void CpuProfile::Print() {
OS::Print("[Top down]:\n");
top_down_.Print();
- OS::Print("[Bottom up]:\n");
- bottom_up_.Print();
}
INLINE(const char* title() const) { return title_; }
INLINE(unsigned uid() const) { return uid_; }
INLINE(const ProfileTree* top_down() const) { return &top_down_; }
- INLINE(const ProfileTree* bottom_up() const) { return &bottom_up_; }
void UpdateTicksScale();
const char* title_;
unsigned uid_;
ProfileTree top_down_;
- ProfileTree bottom_up_;
DISALLOW_COPY_AND_ASSIGN(CpuProfile);
};
const i::List<ProfileNode*>* top_down_ddd_children =
top_down_stub_children->last()->children();
CHECK_EQ(0, top_down_ddd_children->length());
-
- const i::List<ProfileNode*>* bottom_up_root_children_unsorted =
- profile->bottom_up()->root()->children();
- CHECK_EQ(3, bottom_up_root_children_unsorted->length());
- i::List<ProfileNode*> bottom_up_root_children(3);
- bottom_up_root_children.AddAll(*bottom_up_root_children_unsorted);
- bottom_up_root_children.Sort(&CompareProfileNodes);
- CHECK_EQ("5", bottom_up_root_children[0]->entry()->name());
- CHECK_EQ("bbb", bottom_up_root_children[1]->entry()->name());
- CHECK_EQ("ddd", bottom_up_root_children[2]->entry()->name());
- const i::List<ProfileNode*>* bottom_up_stub_children =
- bottom_up_root_children[0]->children();
- CHECK_EQ(1, bottom_up_stub_children->length());
- CHECK_EQ("bbb", bottom_up_stub_children->last()->entry()->name());
- const i::List<ProfileNode*>* bottom_up_bbb_children =
- bottom_up_root_children[1]->children();
- CHECK_EQ(0, bottom_up_bbb_children->length());
- const i::List<ProfileNode*>* bottom_up_ddd_children =
- bottom_up_root_children[2]->children();
- CHECK_EQ(1, bottom_up_ddd_children->length());
- CHECK_EQ("5", bottom_up_ddd_children->last()->entry()->name());
- const i::List<ProfileNode*>* bottom_up_ddd_stub_children =
- bottom_up_ddd_children->last()->children();
- CHECK_EQ(1, bottom_up_ddd_stub_children->length());
- CHECK_EQ("bbb", bottom_up_ddd_stub_children->last()->entry()->name());
}