2021-01-13 02:54:51 +00:00
|
|
|
package collector
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkOsCollect(b *testing.B) {
|
|
|
|
o, err := NewOSCollector()
|
|
|
|
if err != nil {
|
|
|
|
b.Error(err)
|
|
|
|
}
|
|
|
|
metrics := make(chan prometheus.Metric)
|
|
|
|
go func() {
|
|
|
|
for {
|
|
|
|
<-metrics
|
|
|
|
}
|
|
|
|
}()
|
2021-01-19 23:03:16 +00:00
|
|
|
s, err := PrepareScrapeContext([]string{"os"})
|
2021-01-13 02:54:51 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2021-01-19 23:03:16 +00:00
|
|
|
o.Collect(s, metrics)
|
2021-01-13 02:54:51 +00:00
|
|
|
}
|
|
|
|
}
|