]> Cypherpunks repositories - gostls13.git/commitdiff
runtime, time: accelerate tests in short mode.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 14 Feb 2012 21:13:19 +0000 (22:13 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 14 Feb 2012 21:13:19 +0000 (22:13 +0100)
                                   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

src/pkg/runtime/gc_test.go
src/pkg/time/sleep_test.go
src/pkg/time/tick_test.go

index 739ebcba2ff81e1580959ac784471869734b3fdf..65894a6fd01531695c2435efe9064b406d64bbbb 100644 (file)
@@ -15,7 +15,11 @@ func TestGcSys(t *testing.T) {
        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()
        }
 
index b12a5a16818c651e6ae633fc6c24eccaa7939b48..9b0b7f7e06a1efc25e490efc259f22628ef590d5 100644 (file)
@@ -108,10 +108,11 @@ func TestAfter(t *testing.T) {
 }
 
 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)
@@ -176,9 +177,10 @@ func await(slot int, result chan<- afterResult, ac <-chan Time) {
 }
 
 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.
index 36349349ce0ff4644ded7b953a9b3120fa1580b7..0c1c4d67ab00500069fef149992c0e3d4adc7c69 100644 (file)
@@ -10,10 +10,11 @@ import (
 )
 
 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++ {
@@ -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.
 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()
        }