OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package runtime_test | 5 package runtime_test |
6 | 6 |
7 import ( | 7 import ( |
8 "os" | 8 "os" |
9 "runtime" | 9 "runtime" |
10 "runtime/debug" | 10 "runtime/debug" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 func TestGcLastTime(t *testing.T) { | 157 func TestGcLastTime(t *testing.T) { |
158 ms := new(runtime.MemStats) | 158 ms := new(runtime.MemStats) |
159 t0 := time.Now().UnixNano() | 159 t0 := time.Now().UnixNano() |
160 runtime.GC() | 160 runtime.GC() |
161 t1 := time.Now().UnixNano() | 161 t1 := time.Now().UnixNano() |
162 runtime.ReadMemStats(ms) | 162 runtime.ReadMemStats(ms) |
163 last := int64(ms.LastGC) | 163 last := int64(ms.LastGC) |
164 if t0 > last || last > t1 { | 164 if t0 > last || last > t1 { |
165 t.Fatalf("bad last GC time: got %v, want [%v, %v]", last, t0, t1
) | 165 t.Fatalf("bad last GC time: got %v, want [%v, %v]", last, t0, t1
) |
166 } | 166 } |
| 167 pause := ms.PauseNs[(ms.NumGC+255)%256] |
| 168 if pause == 0 || pause > 10e9 { |
| 169 t.Fatalf("bad last GC pause: got %v, want [0, 10e9]", pause) |
| 170 } |
167 } | 171 } |
168 | 172 |
169 var hugeSink interface{} | 173 var hugeSink interface{} |
170 | 174 |
171 func TestHugeGCInfo(t *testing.T) { | 175 func TestHugeGCInfo(t *testing.T) { |
172 // The test ensures that compiler can chew these huge types even on weak
est machines. | 176 // The test ensures that compiler can chew these huge types even on weak
est machines. |
173 // The types are not allocated at runtime. | 177 // The types are not allocated at runtime. |
174 if hugeSink != nil { | 178 if hugeSink != nil { |
175 // 400MB on 32 bots, 4TB on 64-bits. | 179 // 400MB on 32 bots, 4TB on 64-bits. |
176 const n = (400 << 20) + (unsafe.Sizeof(uintptr(0))-4)<<40 | 180 const n = (400 << 20) + (unsafe.Sizeof(uintptr(0))-4)<<40 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 279 } |
276 } | 280 } |
277 }() | 281 }() |
278 for i := 0; i < 1e4; i++ { | 282 for i := 0; i < 1e4; i++ { |
279 func() { | 283 func() { |
280 defer print("") | 284 defer print("") |
281 }() | 285 }() |
282 } | 286 } |
283 close(done) | 287 close(done) |
284 } | 288 } |
OLD | NEW |