Commit 2a6e6999 authored by Rémy Oudompheng's avatar Rémy Oudompheng

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
parent f8f0a2bc
......@@ -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()
}
......
......@@ -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.
......
......@@ -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()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment