From afcdbd3f782d4cc002eaedc0a06d097bbcaf8235 Mon Sep 17 00:00:00 2001 From: lemon-mint Date: Sun, 26 Feb 2023 10:05:34 +0900 Subject: [PATCH] BCache --- cache/.gitkeep | 0 cache/bcache/bcache.go | 10 ++++++++++ sync2/lock_test.go | 39 +++++++++++++++++++++++++++++++++++++++ wyhash-js | 1 - 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 cache/.gitkeep create mode 100644 cache/bcache/bcache.go create mode 100644 sync2/lock_test.go delete mode 160000 wyhash-js diff --git a/cache/.gitkeep b/cache/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/cache/bcache/bcache.go b/cache/bcache/bcache.go new file mode 100644 index 0000000..ec03b0a --- /dev/null +++ b/cache/bcache/bcache.go @@ -0,0 +1,10 @@ +package bcache + +import "sync" + +type BCache struct { +} + +type bucket struct { + l sync.Mutex +} diff --git a/sync2/lock_test.go b/sync2/lock_test.go new file mode 100644 index 0000000..59e7fe0 --- /dev/null +++ b/sync2/lock_test.go @@ -0,0 +1,39 @@ +package sync2_test + +import ( + "sync" + "testing" +) + +func BenchmarkSyncMutexLockUnlock(b *testing.B) { + m := &sync.Mutex{} + b.SetBytes(1) + b.RunParallel(func(p *testing.PB) { + for p.Next() { + m.Lock() + m.Unlock() + } + }) +} + +func BenchmarkSyncRWMutexLockUnlock(b *testing.B) { + m := &sync.RWMutex{} + b.SetBytes(1) + b.RunParallel(func(p *testing.PB) { + for p.Next() { + m.Lock() + m.Unlock() + } + }) +} + +func BenchmarkSyncRWMutexRLockRUnlock(b *testing.B) { + m := &sync.RWMutex{} + b.SetBytes(1) + b.RunParallel(func(p *testing.PB) { + for p.Next() { + m.RLock() + m.RUnlock() + } + }) +} diff --git a/wyhash-js b/wyhash-js deleted file mode 160000 index 8531e30..0000000 --- a/wyhash-js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8531e30132de4ff3c1394ce9a65b9fbec907bf74