chore(*): make everything use goven
for i in github.com/BurntSushi/toml github.com/coreos/go-etcd/etcd github.com/coreos/go-log/log github.com/gorilla/context github.com/rcrowley/go-metrics bitbucket.org/kardianos/osext github.com/coreos/go-systemd/journal github.com/coreos/raft code.google.com/p/goprotobuf/proto ; do goven -copy -rewrite $i; done
This commit is contained in:
46
third_party/github.com/rcrowley/go-metrics/runtime_test.go
vendored
Normal file
46
third_party/github.com/rcrowley/go-metrics/runtime_test.go
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func BenchmarkRuntimeMemStats(b *testing.B) {
|
||||
r := NewRegistry()
|
||||
RegisterRuntimeMemStats(r)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
CaptureRuntimeMemStatsOnce(r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeMemStatsBlocking(t *testing.T) {
|
||||
if g := runtime.GOMAXPROCS(0); g < 2 {
|
||||
t.Skipf("skipping TestRuntimeMemStatsBlocking with GOMAXPROCS=%d\n", g)
|
||||
}
|
||||
ch := make(chan int)
|
||||
go testRuntimeMemStatsBlocking(ch)
|
||||
var memStats runtime.MemStats
|
||||
t0 := time.Now()
|
||||
runtime.ReadMemStats(&memStats)
|
||||
t1 := time.Now()
|
||||
t.Log("i++ during runtime.ReadMemStats:", <-ch)
|
||||
go testRuntimeMemStatsBlocking(ch)
|
||||
d := t1.Sub(t0)
|
||||
t.Log(d)
|
||||
time.Sleep(d)
|
||||
t.Log("i++ during time.Sleep:", <-ch)
|
||||
}
|
||||
|
||||
func testRuntimeMemStatsBlocking(ch chan int) {
|
||||
i := 0
|
||||
for {
|
||||
select {
|
||||
case ch <- i:
|
||||
return
|
||||
default:
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user