diff options
| author | chrislu <chris.lu@gmail.com> | 2023-08-23 00:31:33 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2023-08-23 00:31:33 -0700 |
| commit | 99f037b958b5952628d281461d3bfb76fa433d8c (patch) | |
| tree | 7b82cb004ef223e7c3a63a1aa8a3172c6ac060f8 /weed/operation/assign_file_id_test.go | |
| parent | eac92c334a7b7222b5289cb04733ec87abf36075 (diff) | |
| download | seaweedfs-99f037b958b5952628d281461d3bfb76fa433d8c.tar.xz seaweedfs-99f037b958b5952628d281461d3bfb76fa433d8c.zip | |
streaming assign file ids
Diffstat (limited to 'weed/operation/assign_file_id_test.go')
| -rw-r--r-- | weed/operation/assign_file_id_test.go | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/weed/operation/assign_file_id_test.go b/weed/operation/assign_file_id_test.go new file mode 100644 index 000000000..f6362dceb --- /dev/null +++ b/weed/operation/assign_file_id_test.go @@ -0,0 +1,68 @@ +package operation + +import ( + "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb" + "google.golang.org/grpc" + "testing" + "time" +) + +func BenchmarkWithConcurrency(b *testing.B) { + concurrencyLevels := []int{1, 10, 100, 1000} + + ap, _ := NewAssignProxy(func() pb.ServerAddress { + return pb.ServerAddress("localhost:9333") + }, grpc.WithInsecure(), 16) + + for _, concurrency := range concurrencyLevels { + b.Run( + fmt.Sprintf("Concurrency-%d", concurrency), + func(b *testing.B) { + for i := 0; i < b.N; i++ { + done := make(chan struct{}) + startTime := time.Now() + + for j := 0; j < concurrency; j++ { + go func() { + + ap.Assign(&VolumeAssignRequest{ + Count: 1, + }) + + done <- struct{}{} + }() + } + + for j := 0; j < concurrency; j++ { + <-done + } + + duration := time.Since(startTime) + b.Logf("Concurrency: %d, Duration: %v", concurrency, duration) + } + }, + ) + } +} + +func BenchmarkStreamAssign(b *testing.B) { + ap, _ := NewAssignProxy(func() pb.ServerAddress { + return pb.ServerAddress("localhost:9333") + }, grpc.WithInsecure(), 16) + for i := 0; i < b.N; i++ { + ap.Assign(&VolumeAssignRequest{ + Count: 1, + }) + } +} + +func BenchmarkUnaryAssign(b *testing.B) { + for i := 0; i < b.N; i++ { + Assign(func() pb.ServerAddress { + return pb.ServerAddress("localhost:9333") + }, grpc.WithInsecure(), &VolumeAssignRequest{ + Count: 1, + }) + } +} |
