github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/storage/segment/visualize.go (about) 1 package segment 2 3 import ( 4 "time" 5 ) 6 7 // var highchartsTemplate *template.Template 8 9 func init() { 10 } 11 12 type visualizeNode struct { 13 T1 time.Time 14 T2 time.Time 15 Depth int 16 HasTrie bool 17 } 18 19 // This is here for debugging 20 func (s *Segment) Visualize() { 21 res := []*visualizeNode{} 22 if s.root != nil { 23 nodes := []*streeNode{s.root} 24 for len(nodes) != 0 { 25 n := nodes[0] 26 nodes = nodes[1:] 27 // log.Debug("node:", durations[n.depth]) 28 res = append(res, &visualizeNode{ 29 T1: n.time.UTC(), 30 T2: n.time.Add(durations[n.depth]).UTC(), 31 Depth: n.depth, 32 HasTrie: n.present, 33 }) 34 for _, v := range n.children { 35 if v != nil { 36 nodes = append(nodes, v) 37 } 38 } 39 } 40 } 41 42 // jsonBytes, _ := json.MarshalIndent(res, "", " ") 43 // log.Debug(string(jsonBytes)) 44 }