Skip to content

Commit

Permalink
table: work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
petethepig committed Jan 16, 2021
1 parent 774f0b5 commit 75b4920
Show file tree
Hide file tree
Showing 8 changed files with 3,043 additions and 156 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
"babel-loader": "^8.1.0",
"classnames": "^2.2.6",
"clsx": "^1.1.1",
"color": "^3.1.3",
"file-loader": "^6.2.0",
"humanize-duration": "^3.25.1",
"moment": "^2.27.0",
"normalize.css": "^8.0.1",
"react": "16.12.0",
Expand Down
12 changes: 10 additions & 2 deletions pkg/storage/tree/flamebearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type Flamebearer struct {
Names []string `json:"names"`
Levels [][]int `json:"levels"`
NumTicks int `json:"numTicks"`
MaxSelf int `json:"maxSelf"`
SpyName string `json:"spyName"`
SampleRate int `json:"sampleRate"`
}
Expand All @@ -16,6 +17,7 @@ func (t *Tree) FlamebearerStruct(maxNodes int) *Flamebearer {
Names: []string{},
Levels: [][]int{},
NumTicks: int(t.Samples()),
MaxSelf: int(0),
}

nodes := []*treeNode{t.root}
Expand All @@ -41,6 +43,9 @@ func (t *Tree) FlamebearerStruct(maxNodes int) *Flamebearer {
if i, ok = nameLocationCache[name]; !ok {
i = len(res.Names)
nameLocationCache[name] = i
if i == 0 {
name = "total"
}
res.Names = append(res.Names, name)
}

Expand All @@ -56,7 +61,10 @@ func (t *Tree) FlamebearerStruct(maxNodes int) *Flamebearer {
// prevW := res.Levels[level][len(res.Levels[level])-2]
// barIndex -= prevX + prevW
// }
res.Levels[level] = append([]int{xOffset, int(tn.Total), i}, res.Levels[level]...)
if res.MaxSelf < int(tn.Self) {
res.MaxSelf = int(tn.Self)
}
res.Levels[level] = append([]int{xOffset, int(tn.Total), int(tn.Self), i}, res.Levels[level]...)

xOffset += int(tn.Self)
otherTotal := uint64(0)
Expand Down Expand Up @@ -85,7 +93,7 @@ func (t *Tree) FlamebearerStruct(maxNodes int) *Flamebearer {
}
for _, l := range res.Levels {
prev := 0
for i := 0; i < len(l); i += 3 {
for i := 0; i < len(l); i += 4 {
l[i] -= prev
prev += l[i] + l[i+1]
}
Expand Down

0 comments on commit 75b4920

Please sign in to comment.