| 266 | } |
| 267 | |
| 268 | func BenchmarkCreateWithMaxFD(b *testing.B) { |
| 269 | const maxLimit = 1 << 31 |
| 270 | runTest(b, func(ctx context.Context, _ *FDTable, fd *vfs.FileDescription, limitSet *limits.LimitSet) { |
| 271 | // Remove the previous limit. |
| 272 | limitSet.Set(limits.NumberOfFiles, limits.Limit{maxLimit, maxLimit}, true) |
| 273 | |
| 274 | for i := 0; i < b.N; i++ { |
| 275 | fdTable := new(FDTable) |
| 276 | fdTable.init() |
| 277 | _, err := fdTable.NewFDAt(ctx, maxLimit-1, fd, FDFlags{}) |
| 278 | if err != nil { |
| 279 | b.Fatalf("fdTable.NewFDs: got %v, wanted nil", err) |
| 280 | } |
| 281 | fdTable.DecRef(ctx) |
| 282 | } |
| 283 | }) |
| 284 | } |
| 285 | |
| 286 | func BenchmarkFDLookupAndDecRefConcurrent(b *testing.B) { |
| 287 | b.StopTimer() // Setup. |