summaryrefslogtreecommitdiff
path: root/internal/flamegraph
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-10 22:30:16 +0300
committerPaul Buetow <paul@buetow.org>2025-04-10 22:30:16 +0300
commit1eeae89f5b1fcff41694b311fe699a65788cef6b (patch)
tree28ef5d6702a58edbba92a41b957df897866f0e27 /internal/flamegraph
parent4eca989fa649538e78038999f5e4cc21acca1db9 (diff)
can generate flamegraphs
Diffstat (limited to 'internal/flamegraph')
-rw-r--r--internal/flamegraph/counter.go21
-rw-r--r--internal/flamegraph/iordata.go10
2 files changed, 22 insertions, 9 deletions
diff --git a/internal/flamegraph/counter.go b/internal/flamegraph/counter.go
index 96cfe06..6105136 100644
--- a/internal/flamegraph/counter.go
+++ b/internal/flamegraph/counter.go
@@ -1,5 +1,9 @@
package flamegraph
+import (
+ "fmt"
+)
+
type Counter struct {
Count uint64
Duration uint64
@@ -12,5 +16,22 @@ func (c Counter) add(other Counter) Counter {
c.Duration += other.Duration
c.DurationToPrev += other.DurationToPrev
c.Bytes += other.Bytes
+
return c
}
+
+func (c Counter) ValueByName(name string) uint64 {
+ // Convert the numbers to strings here
+ switch name {
+ case "count":
+ return c.Count
+ case "duration":
+ return c.Duration
+ case "durationToPrev":
+ return c.DurationToPrev
+ case "bytes":
+ return c.Bytes
+ default:
+ panic(fmt.Sprintln("No", name, "in count record"))
+ }
+}
diff --git a/internal/flamegraph/iordata.go b/internal/flamegraph/iordata.go
index 6974329..cef01ff 100644
--- a/internal/flamegraph/iordata.go
+++ b/internal/flamegraph/iordata.go
@@ -198,7 +198,7 @@ type iterRecord struct {
func (ir iterRecord) StringByName(name string) string {
switch name {
case "path":
- return ir.path
+ return strings.Join(strings.Split(ir.path, "/"), ";/")
case "comm":
return ir.comm
case "tracepoint":
@@ -209,14 +209,6 @@ func (ir iterRecord) StringByName(name string) string {
return fmt.Sprint(ir.tid)
case "flags":
return ir.flags.String()
- case "count":
- return fmt.Sprint(ir.cnt.Count)
- case "duration":
- return fmt.Sprint(ir.cnt.Duration)
- case "durationToPrev":
- return fmt.Sprint(ir.cnt.DurationToPrev)
- case "bytes":
- return fmt.Sprint(ir.cnt.Bytes)
default:
panic(fmt.Sprintln("No", name, "in record"))
}