summaryrefslogtreecommitdiff
path: root/internal/flamegraph/counter.go
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/counter.go
parent4eca989fa649538e78038999f5e4cc21acca1db9 (diff)
can generate flamegraphs
Diffstat (limited to 'internal/flamegraph/counter.go')
-rw-r--r--internal/flamegraph/counter.go21
1 files changed, 21 insertions, 0 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"))
+ }
+}