github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/queues/lock_test.go (about) 1 // implements fifo using a channel 2 package goqueuestest 3 /* 4 import ( 5 "sync" 6 "testing" 7 ) 8 9 func benchLockChan(b *testing.B) 10 11 func BenchmarkLockChan(b *testing.B) { 12 ch := make(chan int, 1) 13 ch <- 1 14 runParallelBench(b, 8, func(q Queue, N int){ 15 for i := 0; i < N; i += 1 { 16 <- ch 17 ch <- 1 18 } 19 }) 20 } 21 22 func BenchmarkLockMutex(b *testing.B) { 23 m := sync.Mutex{} 24 runParallelBench(b, func(q Queue, N int){ 25 for i := 0; i < N; i += 1 { 26 m.Lock() 27 m.Unlock() 28 } 29 }) 30 }*/