Исходники и презентации

This commit is contained in:
2025-05-23 07:26:39 +03:00
parent aa948179d5
commit 02d8430a3a
514 changed files with 13773 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package main
import (
"fmt"
"testing"
)
var result string
var buffer []byte = make([]byte, 33)
func Concat(b *testing.B) {
for i := 0; i < b.N; i++ {
result = string(buffer) + string(buffer)
}
}
func main() {
b := testing.Benchmark(Concat)
fmt.Println(b.AllocsPerOp()) // 3
fmt.Println(b.AllocedBytesPerOp()) // 176
// alocated 176 bytes = 48 (not 33) + 48 (not 33) + 80 (not 33 + 33 = 66)
// waste = 15 + 15 + 14 = 44 bytes (25% waste)
}