메모리 사용 줄임
This commit is contained in:
parent
6b4fc97216
commit
a2d7f5e720
|
@ -86,18 +86,17 @@ func (m *influxMetric) StartLogging() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ticker := time.Tick(time.Second)
|
ticker := time.Tick(time.Second)
|
||||||
metricData := make([]data, m.processorCount)
|
pastMetricData, newMetricData := make([]data, m.processorCount), make([]data, m.processorCount)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker:
|
case <-ticker:
|
||||||
sendData := make([]data, m.processorCount)
|
copy(pastMetricData, newMetricData)
|
||||||
copy(sendData, metricData)
|
go m.sendPoint(influxDbConn, batchPoint, pastMetricData)
|
||||||
m.sendPoint(influxDbConn, batchPoint, sendData)
|
|
||||||
case changedSpeed := <-m.fanSpeedConsumer:
|
case changedSpeed := <-m.fanSpeedConsumer:
|
||||||
metricData[changedSpeed.Id].FanSpeed = changedSpeed.FanSpeed
|
newMetricData[changedSpeed.Id].FanSpeed = changedSpeed.FanSpeed
|
||||||
case changedTempeture := <-m.tempetureConsumer:
|
case changedTempeture := <-m.tempetureConsumer:
|
||||||
metricData[changedTempeture.Id].Tempeture = changedTempeture.Tempeture
|
newMetricData[changedTempeture.Id].Tempeture = changedTempeture.Tempeture
|
||||||
case <-m.handler.Done():
|
case <-m.handler.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue