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

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,31 @@
package main
import "testing"
// go test -bench=. comparison_test.go
//go:noinline
func withDefer(a, b int) {
defer func() {
Result = a + b
}()
}
//go:noinline
func withoutDefer(a, b int) {
Result = a + b
}
var Result int
func BenchmarkWithDefer(b *testing.B) {
for i := 0; i < b.N; i++ {
withDefer(-1, i)
}
}
func BenchmarkWithoutDefer(b *testing.B) {
for i := 0; i < b.N; i++ {
withoutDefer(-1, i)
}
}