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) | 67 static RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo>> build
InspectorObjectForPositionTicks(const v8::CpuProfileNode* node) |
68 { | 68 { |
69 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > array =
TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo>::create(); | 69 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo>> array =
TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo>::create(); |
70 unsigned lineCount = node->GetHitLineCount(); | 70 unsigned lineCount = node->GetHitLineCount(); |
71 if (!lineCount) | 71 if (!lineCount) |
72 return array; | 72 return array; |
73 | 73 |
74 Vector<v8::CpuProfileNode::LineTick> entries(lineCount); | 74 Vector<v8::CpuProfileNode::LineTick> entries(lineCount); |
75 if (node->GetLineTicks(&entries[0], lineCount)) { | 75 if (node->GetLineTicks(&entries[0], lineCount)) { |
76 for (unsigned i = 0; i < lineCount; i++) { | 76 for (unsigned i = 0; i < lineCount; i++) { |
77 RefPtr<TypeBuilder::Profiler::PositionTickInfo> line = TypeBuilder::
Profiler::PositionTickInfo::create() | 77 RefPtr<TypeBuilder::Profiler::PositionTickInfo> line = TypeBuilder::
Profiler::PositionTickInfo::create() |
78 .setLine(entries[i].line) | 78 .setLine(entries[i].line) |
79 .setTicks(entries[i].hit_count); | 79 .setTicks(entries[i].hit_count); |
80 array->addItem(line); | 80 array->addItem(line); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 return array; | 84 return array; |
85 } | 85 } |
86 | 86 |
87 static PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor
(const v8::CpuProfileNode* node) | 87 static PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> buildInspectorObjectFor
(const v8::CpuProfileNode* node) |
88 { | 88 { |
89 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 89 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
90 | 90 |
91 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(); |
92 const int childrenCount = node->GetChildrenCount(); | 92 const int childrenCount = node->GetChildrenCount(); |
93 for (int i = 0; i < childrenCount; i++) { | 93 for (int i = 0; i < childrenCount; i++) { |
94 const v8::CpuProfileNode* child = node->GetChild(i); | 94 const v8::CpuProfileNode* child = node->GetChild(i); |
95 children->addItem(buildInspectorObjectFor(child)); | 95 children->addItem(buildInspectorObjectFor(child)); |
96 } | 96 } |
97 | 97 |
98 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo> > positio
nTicks = buildInspectorObjectForPositionTicks(node); | 98 RefPtr<TypeBuilder::Array<TypeBuilder::Profiler::PositionTickInfo>> position
Ticks = buildInspectorObjectForPositionTicks(node); |
99 | 99 |
100 RefPtr<TypeBuilder::Profiler::CPUProfileNode> result = TypeBuilder::Profiler
::CPUProfileNode::create() | 100 RefPtr<TypeBuilder::Profiler::CPUProfileNode> result = TypeBuilder::Profiler
::CPUProfileNode::create() |
101 .setFunctionName(toCoreString(node->GetFunctionName())) | 101 .setFunctionName(toCoreString(node->GetFunctionName())) |
102 .setScriptId(String::number(node->GetScriptId())) | 102 .setScriptId(String::number(node->GetScriptId())) |
103 .setUrl(toCoreString(node->GetScriptResourceName())) | 103 .setUrl(toCoreString(node->GetScriptResourceName())) |
104 .setLineNumber(node->GetLineNumber()) | 104 .setLineNumber(node->GetLineNumber()) |
105 .setColumnNumber(node->GetColumnNumber()) | 105 .setColumnNumber(node->GetColumnNumber()) |
106 .setHitCount(node->GetHitCount()) | 106 .setHitCount(node->GetHitCount()) |
107 .setCallUID(node->GetCallUid()) | 107 .setCallUID(node->GetCallUid()) |
108 .setChildren(children.release()) | 108 .setChildren(children.release()) |
109 .setPositionTicks(positionTicks.release()) | 109 .setPositionTicks(positionTicks.release()) |
110 .setDeoptReason(node->GetBailoutReason()) | 110 .setDeoptReason(node->GetBailoutReason()) |
111 .setId(node->GetNodeId()); | 111 .setId(node->GetNodeId()); |
112 return result.release(); | 112 return result.release(); |
113 } | 113 } |
114 | 114 |
115 PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> ScriptProfile::buildInspectorO
bjectForHead() const | 115 PassRefPtr<TypeBuilder::Profiler::CPUProfileNode> ScriptProfile::buildInspectorO
bjectForHead() const |
116 { | 116 { |
117 return buildInspectorObjectFor(m_profile->GetTopDownRoot()); | 117 return buildInspectorObjectFor(m_profile->GetTopDownRoot()); |
118 } | 118 } |
119 | 119 |
120 PassRefPtr<TypeBuilder::Array<int> > ScriptProfile::buildInspectorObjectForSampl
es() const | 120 PassRefPtr<TypeBuilder::Array<int>> ScriptProfile::buildInspectorObjectForSample
s() const |
121 { | 121 { |
122 RefPtr<TypeBuilder::Array<int> > array = TypeBuilder::Array<int>::create(); | 122 RefPtr<TypeBuilder::Array<int>> array = TypeBuilder::Array<int>::create(); |
123 int count = m_profile->GetSamplesCount(); | 123 int count = m_profile->GetSamplesCount(); |
124 for (int i = 0; i < count; i++) | 124 for (int i = 0; i < count; i++) |
125 array->addItem(m_profile->GetSample(i)->GetNodeId()); | 125 array->addItem(m_profile->GetSample(i)->GetNodeId()); |
126 return array.release(); | 126 return array.release(); |
127 } | 127 } |
128 | 128 |
129 PassRefPtr<TypeBuilder::Array<double> > ScriptProfile::buildInspectorObjectForTi
mestamps() const | 129 PassRefPtr<TypeBuilder::Array<double>> ScriptProfile::buildInspectorObjectForTim
estamps() const |
130 { | 130 { |
131 RefPtr<TypeBuilder::Array<double> > array = TypeBuilder::Array<double>::crea
te(); | 131 RefPtr<TypeBuilder::Array<double>> array = TypeBuilder::Array<double>::creat
e(); |
132 int count = m_profile->GetSamplesCount(); | 132 int count = m_profile->GetSamplesCount(); |
133 for (int i = 0; i < count; i++) | 133 for (int i = 0; i < count; i++) |
134 array->addItem(m_profile->GetSampleTimestamp(i)); | 134 array->addItem(m_profile->GetSampleTimestamp(i)); |
135 return array.release(); | 135 return array.release(); |
136 } | 136 } |
137 | 137 |
138 } // namespace blink | 138 } // namespace blink |
OLD | NEW |