LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 time_test | 5 package time_test |
6 | 6 |
7 import ( | 7 import ( |
8 "testing" | 8 "testing" |
9 . "time" | 9 . "time" |
10 ) | 10 ) |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 // Test that a bug tearing down a ticker has been fixed. This routine should no
t deadlock. | 38 // Test that a bug tearing down a ticker has been fixed. This routine should no
t deadlock. |
39 func TestTeardown(t *testing.T) { | 39 func TestTeardown(t *testing.T) { |
40 for i := 0; i < 3; i++ { | 40 for i := 0; i < 3; i++ { |
41 ticker := NewTicker(1e8) | 41 ticker := NewTicker(1e8) |
42 <-ticker.C | 42 <-ticker.C |
43 ticker.Stop() | 43 ticker.Stop() |
44 } | 44 } |
45 } | 45 } |
| 46 |
| 47 func BenchmarkTicker(b *testing.B) { |
| 48 ticker := NewTicker(1) |
| 49 b.ResetTimer() |
| 50 b.StartTimer() |
| 51 for i := 0; i < b.N; i++ { |
| 52 <-ticker.C |
| 53 } |
| 54 b.StopTimer() |
| 55 ticker.Stop() |
| 56 } |
LEFT | RIGHT |