diff options
| author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:40:16 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:40:16 -0800 |
| commit | 13ac778ef2f757c7cd636b4336a2bd6c8f403b43 (patch) | |
| tree | 28b6ebc4aa762e38c45f4b0b69d3aee472ed4c3c /src/pkg/sync/mutex_test.go | |
| parent | e4bd81f903362d998f7bfc02095935408aff0bc5 (diff) | |
| download | golang-13ac778ef2f757c7cd636b4336a2bd6c8f403b43.tar.gz | |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
4th set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/180049
Diffstat (limited to 'src/pkg/sync/mutex_test.go')
| -rw-r--r-- | src/pkg/sync/mutex_test.go | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/pkg/sync/mutex_test.go b/src/pkg/sync/mutex_test.go index 05fef786a..d0e048ed7 100644 --- a/src/pkg/sync/mutex_test.go +++ b/src/pkg/sync/mutex_test.go @@ -7,23 +7,23 @@ package sync_test import ( - "runtime"; - . "sync"; - "testing"; + "runtime" + . "sync" + "testing" ) func HammerSemaphore(s *uint32, loops int, cdone chan bool) { for i := 0; i < loops; i++ { - runtime.Semacquire(s); - runtime.Semrelease(s); + runtime.Semacquire(s) + runtime.Semrelease(s) } - cdone <- true; + cdone <- true } func TestSemaphore(t *testing.T) { - s := new(uint32); - *s = 1; - c := make(chan bool); + s := new(uint32) + *s = 1 + c := make(chan bool) for i := 0; i < 10; i++ { go HammerSemaphore(s, 1000, c) } @@ -33,37 +33,37 @@ func TestSemaphore(t *testing.T) { } func BenchmarkUncontendedSemaphore(b *testing.B) { - s := new(uint32); - *s = 1; - HammerSemaphore(s, b.N, make(chan bool, 2)); + s := new(uint32) + *s = 1 + HammerSemaphore(s, b.N, make(chan bool, 2)) } func BenchmarkContendedSemaphore(b *testing.B) { - b.StopTimer(); - s := new(uint32); - *s = 1; - c := make(chan bool); - runtime.GOMAXPROCS(2); - b.StartTimer(); + b.StopTimer() + s := new(uint32) + *s = 1 + c := make(chan bool) + runtime.GOMAXPROCS(2) + b.StartTimer() - go HammerSemaphore(s, b.N/2, c); - go HammerSemaphore(s, b.N/2, c); - <-c; - <-c; + go HammerSemaphore(s, b.N/2, c) + go HammerSemaphore(s, b.N/2, c) + <-c + <-c } func HammerMutex(m *Mutex, loops int, cdone chan bool) { for i := 0; i < loops; i++ { - m.Lock(); - m.Unlock(); + m.Lock() + m.Unlock() } - cdone <- true; + cdone <- true } func TestMutex(t *testing.T) { - m := new(Mutex); - c := make(chan bool); + m := new(Mutex) + c := make(chan bool) for i := 0; i < 10; i++ { go HammerMutex(m, 1000, c) } @@ -73,19 +73,19 @@ func TestMutex(t *testing.T) { } func BenchmarkUncontendedMutex(b *testing.B) { - m := new(Mutex); - HammerMutex(m, b.N, make(chan bool, 2)); + m := new(Mutex) + HammerMutex(m, b.N, make(chan bool, 2)) } func BenchmarkContendedMutex(b *testing.B) { - b.StopTimer(); - m := new(Mutex); - c := make(chan bool); - runtime.GOMAXPROCS(2); - b.StartTimer(); + b.StopTimer() + m := new(Mutex) + c := make(chan bool) + runtime.GOMAXPROCS(2) + b.StartTimer() - go HammerMutex(m, b.N/2, c); - go HammerMutex(m, b.N/2, c); - <-c; - <-c; + go HammerMutex(m, b.N/2, c) + go HammerMutex(m, b.N/2, c) + <-c + <-c } |
