1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:57:57 -07:00

runtime, time: accelerate tests in short mode.

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
This commit is contained in:
Rémy Oudompheng 2012-02-14 22:13:19 +01:00
parent f8f0a2bc7b
commit 2a6e6999a4
3 changed files with 24 additions and 13 deletions

View File

@ -15,7 +15,11 @@ func TestGcSys(t *testing.T) {
runtime.ReadMemStats(memstats) runtime.ReadMemStats(memstats)
sys := memstats.Sys sys := memstats.Sys
for i := 0; i < 1000000; i++ { itercount := 1000000
if testing.Short() {
itercount = 100000
}
for i := 0; i < itercount; i++ {
workthegc() workthegc()
} }

View File

@ -108,10 +108,11 @@ func TestAfter(t *testing.T) {
} }
func TestAfterTick(t *testing.T) { func TestAfterTick(t *testing.T) {
const ( const Count = 10
Delta = 100 * Millisecond Delta := 100 * Millisecond
Count = 10 if testing.Short() {
) Delta = 10 * Millisecond
}
t0 := Now() t0 := Now()
for i := 0; i < Count; i++ { for i := 0; i < Count; i++ {
<-After(Delta) <-After(Delta)
@ -176,9 +177,10 @@ func await(slot int, result chan<- afterResult, ac <-chan Time) {
} }
func testAfterQueuing(t *testing.T) error { 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 // make the result channel buffered because we don't want
// to depend on channel queueing semantics that might // to depend on channel queueing semantics that might
// possibly change in the future. // possibly change in the future.

View File

@ -10,10 +10,11 @@ import (
) )
func TestTicker(t *testing.T) { func TestTicker(t *testing.T) {
const ( const Count = 10
Delta = 100 * Millisecond Delta := 100 * Millisecond
Count = 10 if testing.Short() {
) Delta = 10 * Millisecond
}
ticker := NewTicker(Delta) ticker := NewTicker(Delta)
t0 := Now() t0 := Now()
for i := 0; i < Count; i++ { for i := 0; i < Count; i++ {
@ -39,8 +40,12 @@ func TestTicker(t *testing.T) {
// Test that a bug tearing down a ticker has been fixed. This routine should not deadlock. // Test that a bug tearing down a ticker has been fixed. This routine should not deadlock.
func TestTeardown(t *testing.T) { func TestTeardown(t *testing.T) {
Delta := 100 * Millisecond
if testing.Short() {
Delta = 20 * Millisecond
}
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
ticker := NewTicker(1e8) ticker := NewTicker(Delta)
<-ticker.C <-ticker.C
ticker.Stop() ticker.Stop()
} }