| 373 | } |
| 374 | |
| 375 | func BenchmarkFileHeader_Compact(b *testing.B) { |
| 376 | for i := 0; i < b.N; i++ { |
| 377 | var header = &bfs.FileHeader{ |
| 378 | Version: 1, |
| 379 | Status: 200, |
| 380 | BodySize: 200, |
| 381 | BodyBlocks: nil, |
| 382 | } |
| 383 | |
| 384 | for j := 0; j < 100; j++ { |
| 385 | header.BodyBlocks = append(header.BodyBlocks, bfs.BlockInfo{ |
| 386 | OriginOffsetFrom: int64(j * 100), |
| 387 | OriginOffsetTo: int64(j * 200), |
| 388 | BFileOffsetFrom: 0, |
| 389 | BFileOffsetTo: 0, |
| 390 | }) |
| 391 | } |
| 392 | |
| 393 | header.Compact() |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | func BenchmarkFileHeader_Encode(b *testing.B) { |
| 398 | runtime.GOMAXPROCS(12) |