]> Cypherpunks repositories - gostls13.git/commitdiff
sync: restore GOMAXPROCS during benchmarks
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 22 Jun 2011 20:20:37 +0000 (16:20 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 22 Jun 2011 20:20:37 +0000 (16:20 -0400)
R=golang-dev
CC=dvyukov, golang-dev
https://golang.org/cl/4631060

src/pkg/sync/mutex_test.go

index f5c20ca49b40fc367de65b6b612b4d526949b06e..9bfdec365fbd2d958db63082b970405a96ce00c8 100644 (file)
@@ -43,7 +43,7 @@ func BenchmarkContendedSemaphore(b *testing.B) {
        s := new(uint32)
        *s = 1
        c := make(chan bool)
-       runtime.GOMAXPROCS(2)
+       defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2))
        b.StartTimer()
 
        go HammerSemaphore(s, b.N/2, c)
@@ -81,7 +81,7 @@ func BenchmarkContendedMutex(b *testing.B) {
        b.StopTimer()
        m := new(Mutex)
        c := make(chan bool)
-       runtime.GOMAXPROCS(2)
+       defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2))
        b.StartTimer()
 
        go HammerMutex(m, b.N/2, c)