Skip to content

Commit

Permalink
Expose HitCount and HitLineCount to CPUProfileNode
Browse files Browse the repository at this point in the history
  • Loading branch information
mnutt committed Feb 10, 2022
1 parent 5e91d3d commit 99bdd18
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cpuprofilenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ type CPUProfileNode struct {
// The number of the column where the function originates.
columnNumber int

// The number of samples recorded in the function
hitCount uint

// The number of lines in which samples were recorded in the function
hitLineCount uint

// The children node of this node.
children []*CPUProfileNode

Expand Down Expand Up @@ -44,6 +50,16 @@ func (c *CPUProfileNode) GetColumnNumber() int {
return c.columnNumber
}

// Returns total samples recorded inside the function
func (c *CPUProfileNode) GetHitCount() uint {
return c.hitCount
}

// Returns total number of lines inside the function recording samples
func (c *CPUProfileNode) GetHitLineCount() uint {
return c.hitLineCount
}

// Retrieves the ancestor node, or nil if the root.
func (c *CPUProfileNode) GetParent() *CPUProfileNode {
return c.parent
Expand Down
2 changes: 2 additions & 0 deletions cpuprofiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func newCPUProfileNode(node *C.CPUProfileNode, parent *CPUProfileNode) *CPUProfi
functionName: C.GoString(node.functionName),
lineNumber: int(node.lineNumber),
columnNumber: int(node.columnNumber),
hitCount: uint(node.hitCount),
hitLineCount: uint(node.hitLineCount),
parent: parent,
}

Expand Down
2 changes: 2 additions & 0 deletions v8go.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ CPUProfileNode* NewCPUProfileNode(const CpuProfileNode* ptr_) {
ptr_->GetFunctionNameStr(),
ptr_->GetLineNumber(),
ptr_->GetColumnNumber(),
ptr_->GetHitCount(),
ptr_->GetHitLineCount(),
count,
children,
};
Expand Down
2 changes: 2 additions & 0 deletions v8go.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ typedef struct CPUProfileNode {
const char* functionName;
int lineNumber;
int columnNumber;
unsigned int hitCount;
unsigned int hitLineCount;
int childrenCount;
struct CPUProfileNode** children;
} CPUProfileNode;
Expand Down

0 comments on commit 99bdd18

Please sign in to comment.