Skip to content

Commit

Permalink
bad copy of file
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Collison committed Apr 25, 2014
1 parent ac975a9 commit 2141cc7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package server

import (
"strconv"
"testing"
"sync"
"testing"
)

func BenchmarkParseInt(b *testing.B) {
Expand All @@ -24,16 +24,28 @@ func BenchmarkParseSize(b *testing.B) {
}
}

func deferUnlock() {
mu sync.Mutex
func deferUnlock(mu sync.Mutex) {
mu.Lock()
defer mu.Unlock()
}

func BenchmarkDeferMutex(b *testing.B) {
var mu sync.Mutex
b.SetBytes(1)
for i := 0; i < b.N; i++ {
deferUnlock()
deferUnlock(mu)
}
}

func noDeferUnlock(mu sync.Mutex) {
mu.Lock()
mu.Unlock()
}

func BenchmarkNoDeferMutex(b *testing.B) {
var mu sync.Mutex
b.SetBytes(1)
for i := 0; i < b.N; i++ {
noDeferUnlock(mu)
}
}

0 comments on commit 2141cc7

Please sign in to comment.