before after
go test -short time 4.144s 1.215s
go test -short runtime 1.315s 0.351s
go test -short -cpu=1,2,4 runtime 4.376s 1.266s
Partially solves issue 3015.
R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/
5673045
runtime.ReadMemStats(memstats)
sys := memstats.Sys
- for i := 0; i < 1000000; i++ {
+ itercount := 1000000
+ if testing.Short() {
+ itercount = 100000
+ }
+ for i := 0; i < itercount; i++ {
workthegc()
}
}
func TestAfterTick(t *testing.T) {
- const (
- Delta = 100 * Millisecond
- Count = 10
- )
+ const Count = 10
+ Delta := 100 * Millisecond
+ if testing.Short() {
+ Delta = 10 * Millisecond
+ }
t0 := Now()
for i := 0; i < Count; i++ {
<-After(Delta)
}
func testAfterQueuing(t *testing.T) error {
- const (
- Delta = 100 * Millisecond
- )
+ Delta := 100 * Millisecond
+ if testing.Short() {
+ Delta = 20 * Millisecond
+ }
// make the result channel buffered because we don't want
// to depend on channel queueing semantics that might
// possibly change in the future.
)
func TestTicker(t *testing.T) {
- const (
- Delta = 100 * Millisecond
- Count = 10
- )
+ const Count = 10
+ Delta := 100 * Millisecond
+ if testing.Short() {
+ Delta = 10 * Millisecond
+ }
ticker := NewTicker(Delta)
t0 := Now()
for i := 0; i < Count; i++ {
// Test that a bug tearing down a ticker has been fixed. This routine should not deadlock.
func TestTeardown(t *testing.T) {
+ Delta := 100 * Millisecond
+ if testing.Short() {
+ Delta = 20 * Millisecond
+ }
for i := 0; i < 3; i++ {
- ticker := NewTicker(1e8)
+ ticker := NewTicker(Delta)
<-ticker.C
ticker.Stop()
}