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

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,30 @@
package main
import (
"fmt"
"testing"
)
var result string
func Concat(b *testing.B) {
for i := 0; i < b.N; i++ {
result = "Hello" + " world"
}
}
func Conversion(b *testing.B) {
for i := 0; i < b.N; i++ {
result = string([]byte("Hello world"))
}
}
func main() {
b1 := testing.Benchmark(Concat)
fmt.Println("b1:", b1.AllocsPerOp()) // 0
fmt.Println("b1:", b1.AllocedBytesPerOp()) // 0
b2 := testing.Benchmark(Conversion)
fmt.Println("b2:", b2.AllocsPerOp()) // 1
fmt.Println("b2:", b2.AllocedBytesPerOp()) // 16
}