mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
Added start/stop methods to profiler
This commit is contained in:
@@ -72,6 +72,7 @@ type Profile struct {
|
||||
stats []Stat
|
||||
keyFilters []string
|
||||
fingerprinter fingerprinter.Fingerprinter
|
||||
running bool
|
||||
}
|
||||
|
||||
func NewProfiler(iterator Iter, filters []filter.Filter, ticker chan time.Time, fp fingerprinter.Fingerprinter) Profiler {
|
||||
@@ -91,11 +92,16 @@ func (p *Profile) StatsChan() chan []Stat {
|
||||
}
|
||||
|
||||
func (p *Profile) Start() {
|
||||
go p.getData()
|
||||
if !p.running {
|
||||
p.running = true
|
||||
go p.getData()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Profile) Stop() {
|
||||
p.stopChan <- true
|
||||
if p.running {
|
||||
p.stopChan <- true
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Profile) getData() {
|
||||
@@ -165,10 +171,11 @@ func (p *Profile) getData() {
|
||||
}
|
||||
|
||||
p.statsChan <- statsToArray(stats)
|
||||
p.running = false
|
||||
}
|
||||
|
||||
func statsToArray(stats map[StatsGroupKey]*Stat) []Stat {
|
||||
sa := make([]Stat, len(stats))
|
||||
sa := []Stat{}
|
||||
for _, s := range stats {
|
||||
sa = append(sa, *s)
|
||||
}
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user