Skip to content

Commit

Permalink
adding additional profile values (rogchap#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmurakami authored Nov 2, 2022
1 parent fc8b9f1 commit 1f00b50
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cpuprofilenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -17,13 +23,29 @@ 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

// The parent node of this node.
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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cpuprofiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
4 changes: 4 additions & 0 deletions v8go.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 4 additions & 0 deletions v8go.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1f00b50

Please sign in to comment.