(b *testing.B)
| 284 | } |
| 285 | |
| 286 | func BenchmarkFDLookupAndDecRefConcurrent(b *testing.B) { |
| 287 | b.StopTimer() // Setup. |
| 288 | |
| 289 | runTest(b, func(ctx context.Context, fdTable *FDTable, fd *vfs.FileDescription, _ *limits.LimitSet) { |
| 290 | fds, err := fdTable.NewFDs(ctx, 0, []*vfs.FileDescription{fd, fd, fd, fd, fd}, FDFlags{}) |
| 291 | if err != nil { |
| 292 | b.Fatalf("fdTable.NewFDs: got %v, wanted nil", err) |
| 293 | } |
| 294 | |
| 295 | concurrency := runtime.GOMAXPROCS(0) |
| 296 | if concurrency < 4 { |
| 297 | concurrency = 4 |
| 298 | } |
| 299 | each := b.N / concurrency |
| 300 | |
| 301 | b.StartTimer() // Benchmark. |
| 302 | var wg sync.WaitGroup |
| 303 | for i := 0; i < concurrency; i++ { |
| 304 | wg.Add(1) |
| 305 | go func() { |
| 306 | defer wg.Done() |
| 307 | for i := 0; i < each; i++ { |
| 308 | tf, _ := fdTable.Get(fds[i%len(fds)]) |
| 309 | tf.DecRef(ctx) |
| 310 | } |
| 311 | }() |
| 312 | } |
| 313 | wg.Wait() |
| 314 | }) |
| 315 | } |
| 316 | |
| 317 | func TestSetFlagsForRange(t *testing.T) { |
| 318 | type testCase struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…