Skip to content

Commit

Permalink
Some small fixes for lineTicks in cpu profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed May 12, 2015
1 parent 483eea5 commit 1a24629
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/cpu_profile_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ namespace nodex {

uint32_t ProfileNode::UIDCounter = 1;

#if (NODE_MODULE_VERSION >= 42)
static Handle<Value> GetLineTicks(const CpuProfileNode* node) {
#if (NODE_MODULE_VERSION >= 42)
Handle<Value> ProfileNode::GetLineTicks_(const CpuProfileNode* node) {
NanEscapableScope();

unsigned int count = node->GetHitLineCount();
uint32_t count = node->GetHitLineCount();
v8::CpuProfileNode::LineTick *entries = new v8::CpuProfileNode::LineTick[count];
bool result = node->GetLineTicks(entries, count);

Local<Value> lineTicks;
if (result) {
Local<Array> array = NanNew<Array>(count);
for (unsigned int index = 0; index < count; index++) {
for (uint32_t index = 0; index < count; index++) {
Local<Object> tick = NanNew<Object>();
tick->Set(NanNew<String>("line"), NanNew<Integer>(entries[index].line));
tick->Set(NanNew<String>("hitCount"), NanNew<Integer>(entries[index].hit_count));
Expand Down Expand Up @@ -69,7 +69,7 @@ namespace nodex {
profile_node->Set(NanNew<String>("children"), children);

#if (NODE_MODULE_VERSION >= 42)
auto lineTicks = GetLineTicks(node);
Handle<Value> lineTicks = GetLineTicks_(node);
if (!lineTicks->IsNull()) {
profile_node->Set(NanNew<String>("lineTicks"), lineTicks);
}
Expand Down
11 changes: 8 additions & 3 deletions src/cpu_profile_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
namespace nodex {

class ProfileNode {
public:
static v8::Handle<v8::Value> New(const v8::CpuProfileNode* node);
static uint32_t UIDCounter;
public:
static v8::Handle<v8::Value> New(const v8::CpuProfileNode* node);
static uint32_t UIDCounter;

private:
#if (NODE_MODULE_VERSION >= 42)
static v8::Handle<v8::Value> GetLineTicks_(const v8::CpuProfileNode* node);
#endif
};

}
Expand Down

0 comments on commit 1a24629

Please sign in to comment.