blob: 5a162c910efd92ad8df242094ea55afcc490608b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package flamegraph
import (
"fmt"
)
type Counter struct {
Count uint64
Duration uint64
DurationToPrev uint64
Bytes uint64 // TODO: implement
}
func (c Counter) add(other Counter) Counter {
c.Count += other.Count
c.Duration += other.Duration
c.DurationToPrev += other.DurationToPrev
c.Bytes += other.Bytes
return c
}
func (c Counter) ValueByName(name string) uint64 {
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"))
}
}
|