Refactor collectors

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2023-11-04 20:51:35 +01:00
parent 569f5450cd
commit 0711268d3c
207 changed files with 15220 additions and 13648 deletions

View File

@@ -0,0 +1,41 @@
package perflib
import (
"fmt"
"testing"
)
func ExampleQueryPerformanceData() {
objects, err := QueryPerformanceData("2")
if err != nil {
panic(err)
}
for _, object := range objects {
fmt.Printf("%d %s [%d counters, %d instances]\n",
object.NameIndex, object.Name, len(object.CounterDefs), len(object.Instances))
for _, instance := range object.Instances {
if !((instance.Name == "_Total") || (instance.Name == "")) {
continue
}
if instance.Name == "" {
fmt.Println("No instance.", instance.Name)
} else {
fmt.Println("Instance:", instance.Name)
}
for _, counter := range instance.Counters {
fmt.Printf(" -> %s %d\n", counter.Def.Name, counter.Def.NameIndex)
}
}
}
}
func BenchmarkQueryPerformanceData(b *testing.B) {
for n := 0; n < b.N; n++ {
_, _ = QueryPerformanceData("Global")
}
}