github.com/theQRL/go-zond@v0.1.1/metrics/internal/sampledata_test.go (about)

     1  package internal
     2  
     3  import (
     4  	"bytes"
     5  	"encoding/gob"
     6  	"fmt"
     7  	metrics2 "runtime/metrics"
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/theQRL/go-zond/metrics"
    12  )
    13  
    14  func TestCollectRuntimeMetrics(t *testing.T) {
    15  	t.Skip("Only used for generating testdata")
    16  	serialize := func(path string, histogram *metrics2.Float64Histogram) {
    17  		var f = new(bytes.Buffer)
    18  		if err := gob.NewEncoder(f).Encode(histogram); err != nil {
    19  			panic(err)
    20  		}
    21  		fmt.Printf("var %v = %q\n", path, f.Bytes())
    22  	}
    23  	time.Sleep(2 * time.Second)
    24  	stats := metrics.ReadRuntimeStats()
    25  	serialize("schedlatency", stats.SchedLatency)
    26  	serialize("gcpauses", stats.GCPauses)
    27  }