diff options
Diffstat (limited to 'internal/flamegraph/counter.go')
| -rw-r--r-- | internal/flamegraph/counter.go | 21 |
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")) + } +} |
