Skip to content

Commit 1f00b50

Browse files
authored
adding additional profile values (#341)
1 parent fc8b9f1 commit 1f00b50

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

cpuprofilenode.go

+32
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
package v8go
66

77
type CPUProfileNode struct {
8+
// The id of the current node, unique within the tree.
9+
nodeId int
10+
11+
// The id of the script where the function originates.
12+
scriptId int
13+
814
// The resource name for script from where the function originates.
915
scriptResourceName string
1016

@@ -17,13 +23,29 @@ type CPUProfileNode struct {
1723
// The number of the column where the function originates.
1824
columnNumber int
1925

26+
// The count of samples where the function was currently executing.
27+
hitCount int
28+
29+
// The bailout reason for the function if the optimization was disabled for it.
30+
bailoutReason string
31+
2032
// The children node of this node.
2133
children []*CPUProfileNode
2234

2335
// The parent node of this node.
2436
parent *CPUProfileNode
2537
}
2638

39+
// Returns node id.
40+
func (c *CPUProfileNode) GetNodeId() int {
41+
return c.nodeId
42+
}
43+
44+
// Returns id for script from where the function originates.
45+
func (c *CPUProfileNode) GetScriptId() int {
46+
return c.scriptId
47+
}
48+
2749
// Returns function name (empty string for anonymous functions.)
2850
func (c *CPUProfileNode) GetFunctionName() string {
2951
return c.functionName
@@ -44,6 +66,16 @@ func (c *CPUProfileNode) GetColumnNumber() int {
4466
return c.columnNumber
4567
}
4668

69+
// Returns count of samples where the function was currently executing.
70+
func (c *CPUProfileNode) GetHitCount() int {
71+
return c.hitCount
72+
}
73+
74+
// Returns the bailout reason for the function if the optimization was disabled for it.
75+
func (c *CPUProfileNode) GetBailoutReason() string {
76+
return c.bailoutReason
77+
}
78+
4779
// Retrieves the ancestor node, or nil if the root.
4880
func (c *CPUProfileNode) GetParent() *CPUProfileNode {
4981
return c.parent

cpuprofiler.go

+4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@ func (c *CPUProfiler) StopProfiling(title string) *CPUProfile {
7575

7676
func newCPUProfileNode(node *C.CPUProfileNode, parent *CPUProfileNode) *CPUProfileNode {
7777
n := &CPUProfileNode{
78+
nodeId: int(node.nodeId),
79+
scriptId: int(node.scriptId),
7880
scriptResourceName: C.GoString(node.scriptResourceName),
7981
functionName: C.GoString(node.functionName),
8082
lineNumber: int(node.lineNumber),
8183
columnNumber: int(node.columnNumber),
84+
hitCount: int(node.hitCount),
85+
bailoutReason: C.GoString(node.bailoutReason),
8286
parent: parent,
8387
}
8488

v8go.cc

+4
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,14 @@ CPUProfileNode* NewCPUProfileNode(const CpuProfileNode* ptr_) {
328328

329329
CPUProfileNode* root = new CPUProfileNode{
330330
ptr_,
331+
ptr_->GetNodeId(),
332+
ptr_->GetScriptId(),
331333
ptr_->GetScriptResourceNameStr(),
332334
ptr_->GetFunctionNameStr(),
333335
ptr_->GetLineNumber(),
334336
ptr_->GetColumnNumber(),
337+
ptr_->GetHitCount(),
338+
ptr_->GetBailoutReason(),
335339
count,
336340
children,
337341
};

v8go.h

+4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,14 @@ typedef struct {
8484

8585
typedef struct CPUProfileNode {
8686
CpuProfileNodePtr ptr;
87+
unsigned nodeId;
88+
int scriptId;
8789
const char* scriptResourceName;
8890
const char* functionName;
8991
int lineNumber;
9092
int columnNumber;
93+
unsigned hitCount;
94+
const char* bailoutReason;
9195
int childrenCount;
9296
struct CPUProfileNode** children;
9397
} CPUProfileNode;

0 commit comments

Comments
 (0)