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