Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose HitCount and HitLineCount to CPUProfileNode #285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be open to using the comment from the v8 header file for these?

i.e.

// The count of samples where the function was currently executing.
hitCount uint
// The number of the function's source lines that collect the samples.
hitLineCount 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
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the getters ^


// 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