Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1239)

Delta Between Two Patch Sets: src/pkg/time/sleep_test.go

Issue 12876047: code review 12876047: time: lower level interface to Timer: embedding, compac...
Left Patch Set: diff -r 9810b5abd0ab https://code.google.com/p/go Created 10 years, 7 months ago
Right Patch Set: diff -r 9810b5abd0ab https://code.google.com/p/go Created 10 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/time/sleep.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 "runtime" 10 "runtime"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 type expirePointer struct { 149 type expirePointer struct {
150 t *Timer 150 t *Timer
151 } 151 }
152 152
153 func (e *expirePointer) Expire() { 153 func (e *expirePointer) Expire() {
154 } 154 }
155 155
156 type expireEmbed struct { 156 type expireEmbed struct {
157 » t Timer 157 » t EmbedTimer
158 } 158 }
159 159
160 func (e *expireEmbed) Expire() { 160 func (e *expireEmbed) Expire() {
161 } 161 }
162 162
163 func BenchmarkPointerAfterFunc(b *testing.B) { 163 func BenchmarkPointerStop(b *testing.B) {
164 benchmark(b, func(n int) { 164 benchmark(b, func(n int) {
165 e := make([]expirePointer, n) 165 e := make([]expirePointer, n)
166 for i := range e { 166 for i := range e {
167 e[i].t = AfterFunc(Hour, e[i].Expire) 167 e[i].t = AfterFunc(Hour, e[i].Expire)
168 } 168 }
169 for i := range e { 169 for i := range e {
170 e[i].t.Stop() 170 e[i].t.Stop()
171 e[i].t = nil 171 e[i].t = nil
172 } 172 }
173 }) 173 })
174 } 174 }
175 175
176 func BenchmarkEmbedSetupExpire(b *testing.B) { 176 func BenchmarkEmbedStop(b *testing.B) {
177 benchmark(b, func(n int) { 177 benchmark(b, func(n int) {
178 e := make([]expireEmbed, n) 178 e := make([]expireEmbed, n)
179 for i := range e { 179 for i := range e {
180 e[i].t.SetupExpire(Hour, &e[i]) 180 e[i].t.SetupExpire(Hour, &e[i])
181 } 181 }
182 for i := range e { 182 for i := range e {
183 e[i].t.Deinitialize() 183 e[i].t.Deinitialize()
184 } 184 }
185 }) 185 })
186 } 186 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 if r := recover(); r == nil { 428 if r := recover(); r == nil {
429 t.Error("Expected panic, but none happened.") 429 t.Error("Expected panic, but none happened.")
430 } 430 }
431 }() 431 }()
432 432
433 // cause a panic due to a segfault 433 // cause a panic due to a segfault
434 var timer *Timer 434 var timer *Timer
435 timer.Stop() 435 timer.Stop()
436 t.Error("Should be unreachable.") 436 t.Error("Should be unreachable.")
437 } 437 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b