We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7106d86 commit cd652a1Copy full SHA for cd652a1
tests/go_test.go
@@ -2573,3 +2573,21 @@ func BenchmarkBuildGold(b *testing.B) {
2573
bldr.Finish(mon)
2574
}
2575
2576
+
2577
+// Benchmark adding 130 bytes, one by one.
2578
+// Unlike BenchmarkBuildGold, we create a new builder every time,
2579
+// to test the performance of growing the buffer.
2580
+func BenchmarkBuildAllocations(b *testing.B) {
2581
+ b.SetBytes(130)
2582
+ b.ReportAllocs()
2583
+ b.ResetTimer()
2584
+ for i := 0; i < b.N; i++ {
2585
+ bldr := flatbuffers.NewBuilder(0)
2586
+ for j := 0; j < 130; j++ {
2587
+ bldr.PrependByte(byte(j))
2588
+ }
2589
+ if len(bldr.Bytes) != 256 {
2590
+ b.Fatalf("expected buffer size=256, got %d", len(bldr.Bytes))
2591
2592
2593
+}
0 commit comments