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

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,25 @@
package main
import "testing"
// go test -bench=. -benchmem reservation_test.go
func BenchmarkWithoutReservation(b *testing.B) {
sourseData := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}
for i := 0; i < b.N; i++ {
targetData := make([]int, 0)
for j := 0; j < len(sourseData); j++ {
targetData = append(targetData, sourseData[j])
}
}
}
func BenchmarkWithReservation(b *testing.B) {
sourseData := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}
for i := 0; i < b.N; i++ {
targetData := make([]int, 0, len(sourseData))
for j := 0; j < len(sourseData); j++ {
targetData = append(targetData, sourseData[j])
}
}
}