diff --git a/cpuprofilenode.go b/cpuprofilenode.go index fe611792..2a2934b8 100644 --- a/cpuprofilenode.go +++ b/cpuprofilenode.go @@ -5,6 +5,12 @@ package v8go type CPUProfileNode struct { + // The id of the current node, unique within the tree. + nodeId int + + // The id of the script where the function originates. + scriptId int + // The resource name for script from where the function originates. scriptResourceName string @@ -17,6 +23,12 @@ type CPUProfileNode struct { // The number of the column where the function originates. columnNumber int + // The count of samples where the function was currently executing. + hitCount int + + // The bailout reason for the function if the optimization was disabled for it. + bailoutReason string + // The children node of this node. children []*CPUProfileNode @@ -24,6 +36,16 @@ type CPUProfileNode struct { parent *CPUProfileNode } +// Returns node id. +func (c *CPUProfileNode) GetNodeId() int { + return c.nodeId +} + +// Returns id for script from where the function originates. +func (c *CPUProfileNode) GetScriptId() int { + return c.scriptId +} + // Returns function name (empty string for anonymous functions.) func (c *CPUProfileNode) GetFunctionName() string { return c.functionName @@ -44,6 +66,16 @@ func (c *CPUProfileNode) GetColumnNumber() int { return c.columnNumber } +// Returns count of samples where the function was currently executing. +func (c *CPUProfileNode) GetHitCount() int { + return c.hitCount +} + +// Returns the bailout reason for the function if the optimization was disabled for it. +func (c *CPUProfileNode) GetBailoutReason() string { + return c.bailoutReason +} + // Retrieves the ancestor node, or nil if the root. func (c *CPUProfileNode) GetParent() *CPUProfileNode { return c.parent diff --git a/cpuprofiler.go b/cpuprofiler.go index 30bc2457..bd2484b9 100644 --- a/cpuprofiler.go +++ b/cpuprofiler.go @@ -75,10 +75,14 @@ func (c *CPUProfiler) StopProfiling(title string) *CPUProfile { func newCPUProfileNode(node *C.CPUProfileNode, parent *CPUProfileNode) *CPUProfileNode { n := &CPUProfileNode{ + nodeId: int(node.nodeId), + scriptId: int(node.scriptId), scriptResourceName: C.GoString(node.scriptResourceName), functionName: C.GoString(node.functionName), lineNumber: int(node.lineNumber), columnNumber: int(node.columnNumber), + hitCount: int(node.hitCount), + bailoutReason: C.GoString(node.bailoutReason), parent: parent, } diff --git a/v8go.cc b/v8go.cc index 97390883..e55bf45f 100644 --- a/v8go.cc +++ b/v8go.cc @@ -328,10 +328,14 @@ CPUProfileNode* NewCPUProfileNode(const CpuProfileNode* ptr_) { CPUProfileNode* root = new CPUProfileNode{ ptr_, + ptr_->GetNodeId(), + ptr_->GetScriptId(), ptr_->GetScriptResourceNameStr(), ptr_->GetFunctionNameStr(), ptr_->GetLineNumber(), ptr_->GetColumnNumber(), + ptr_->GetHitCount(), + ptr_->GetBailoutReason(), count, children, }; diff --git a/v8go.h b/v8go.h index 7acaf042..bd492c55 100644 --- a/v8go.h +++ b/v8go.h @@ -84,10 +84,14 @@ typedef struct { typedef struct CPUProfileNode { CpuProfileNodePtr ptr; + unsigned nodeId; + int scriptId; const char* scriptResourceName; const char* functionName; int lineNumber; int columnNumber; + unsigned hitCount; + const char* bailoutReason; int childrenCount; struct CPUProfileNode** children; } CPUProfileNode;