OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 double ScriptProfile::startTime() const | 57 double ScriptProfile::startTime() const |
58 { | 58 { |
59 return static_cast<double>(m_profile->GetStartTime()) / 1000000; | 59 return static_cast<double>(m_profile->GetStartTime()) / 1000000; |
60 } | 60 } |
61 | 61 |
62 double ScriptProfile::endTime() const | 62 double ScriptProfile::endTime() const |
63 { | 63 { |
64 return static_cast<double>(m_profile->GetEndTime()) / 1000000; | 64 return static_cast<double>(m_profile->GetEndTime()) / 1000000; |
65 } | 65 } |
66 | 66 |
| 67 static RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > buil
dInspectorObjectForPositionTicks(const v8::CpuProfileNode* node) |
| 68 { |
| 69 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > array =
TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo>::create(); |
| 70 unsigned lineCount = node->GetHitLineCount(); |
| 71 if (!lineCount) |
| 72 return array; |
| 73 |
| 74 Vector<v8::CpuProfileNode::LineTick> entries(lineCount); |
| 75 if (node->GetLineTicks(&entries[0], lineCount)) { |
| 76 for (unsigned i = 0; i < lineCount; i++) { |
| 77 RefPtr<TypeBuilder::Profiler::PositionTickInfo> line = TypeBuilder::
Profiler::PositionTickInfo::create() |
| 78 .setLine(entries[i].line) |
| 79 .setTicks(entries[i].hit_count); |
| 80 array->addItem(line); |
| 81 } |
| 82 } |
| 83 |
| 84 return array; |
| 85 } |
| 86 |
67 static PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor
(const v8::CpuProfileNode* node) | 87 static PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor
(const v8::CpuProfileNode* node) |
68 { | 88 { |
69 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 89 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
70 | 90 |
71 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::CPUProfileNode> > children
= TypeBuilder::Array<TypeBuilder::Profiler::CPUProfileNode>::create(); | 91 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::CPUProfileNode> > children
= TypeBuilder::Array<TypeBuilder::Profiler::CPUProfileNode>::create(); |
72 const int childrenCount = node->GetChildrenCount(); | 92 const int childrenCount = node->GetChildrenCount(); |
73 for (int i = 0; i < childrenCount; i++) { | 93 for (int i = 0; i < childrenCount; i++) { |
74 const v8::CpuProfileNode* child = node->GetChild(i); | 94 const v8::CpuProfileNode* child = node->GetChild(i); |
75 children->addItem(buildInspectorObjectFor(child)); | 95 children->addItem(buildInspectorObjectFor(child)); |
76 } | 96 } |
77 | 97 |
| 98 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > positio
nTicks = buildInspectorObjectForPositionTicks(node); |
| 99 |
78 RefPtr<TypeBuilder::Profiler::CPUProfileNode> result = TypeBuilder::Profiler
::CPUProfileNode::create() | 100 RefPtr<TypeBuilder::Profiler::CPUProfileNode> result = TypeBuilder::Profiler
::CPUProfileNode::create() |
79 .setFunctionName(toCoreString(node->GetFunctionName())) | 101 .setFunctionName(toCoreString(node->GetFunctionName())) |
80 .setScriptId(String::number(node->GetScriptId())) | 102 .setScriptId(String::number(node->GetScriptId())) |
81 .setUrl(toCoreString(node->GetScriptResourceName())) | 103 .setUrl(toCoreString(node->GetScriptResourceName())) |
82 .setLineNumber(node->GetLineNumber()) | 104 .setLineNumber(node->GetLineNumber()) |
83 .setColumnNumber(node->GetColumnNumber()) | 105 .setColumnNumber(node->GetColumnNumber()) |
84 .setHitCount(node->GetHitCount()) | 106 .setHitCount(node->GetHitCount()) |
85 .setCallUID(node->GetCallUid()) | 107 .setCallUID(node->GetCallUid()) |
86 .setChildren(children.release()) | 108 .setChildren(children.release()) |
| 109 .setPositionTicks(positionTicks.release()) |
87 .setDeoptReason(node->GetBailoutReason()) | 110 .setDeoptReason(node->GetBailoutReason()) |
88 .setId(node->GetNodeId()); | 111 .setId(node->GetNodeId()); |
89 return result.release(); | 112 return result.release(); |
90 } | 113 } |
91 | 114 |
92 PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> ScriptProfile::buildInspectorO
bjectForHead() const | 115 PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> ScriptProfile::buildInspectorO
bjectForHead() const |
93 { | 116 { |
94 return buildInspectorObjectFor(m_profile->GetTopDownRoot()); | 117 return buildInspectorObjectFor(m_profile->GetTopDownRoot()); |
95 } | 118 } |
96 | 119 |
97 PassRefPtr<TypeBuilder::Array<int> > ScriptProfile::buildInspectorObjectForSampl
es() const | 120 PassRefPtr<TypeBuilder::Array<int> > ScriptProfile::buildInspectorObjectForSampl
es() const |
98 { | 121 { |
99 RefPtr<TypeBuilder::Array<int> > array = TypeBuilder::Array<int>::create(); | 122 RefPtr<TypeBuilder::Array<int> > array = TypeBuilder::Array<int>::create(); |
100 int count = m_profile->GetSamplesCount(); | 123 int count = m_profile->GetSamplesCount(); |
101 for (int i = 0; i < count; i++) | 124 for (int i = 0; i < count; i++) |
102 array->addItem(m_profile->GetSample(i)->GetNodeId()); | 125 array->addItem(m_profile->GetSample(i)->GetNodeId()); |
103 return array.release(); | 126 return array.release(); |
104 } | 127 } |
105 | 128 |
106 PassRefPtr<TypeBuilder::Array<double> > ScriptProfile::buildInspectorObjectForTi
mestamps() const | 129 PassRefPtr<TypeBuilder::Array<double> > ScriptProfile::buildInspectorObjectForTi
mestamps() const |
107 { | 130 { |
108 RefPtr<TypeBuilder::Array<double> > array = TypeBuilder::Array<double>::crea
te(); | 131 RefPtr<TypeBuilder::Array<double> > array = TypeBuilder::Array<double>::crea
te(); |
109 int count = m_profile->GetSamplesCount(); | 132 int count = m_profile->GetSamplesCount(); |
110 for (int i = 0; i < count; i++) | 133 for (int i = 0; i < count; i++) |
111 array->addItem(m_profile->GetSampleTimestamp(i)); | 134 array->addItem(m_profile->GetSampleTimestamp(i)); |
112 return array.release(); | 135 return array.release(); |
113 } | 136 } |
114 | 137 |
115 } // namespace blink | 138 } // namespace blink |
OLD | NEW |