πββοΈ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "github.com/gofiber/fiber" | |
| "github.com/gofiber/redirect" | |
| ) | |
| func main() { | |
| app := fiber.New() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| "github.com/gen2brain/beeep" | |
| ) | |
| func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func useAppendWithoutLength() { | |
| var arr = []int{} | |
| for i := 0; i < size; i++ { | |
| arr = append(arr, i) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func useAppendWithLength() { | |
| var arr = make([]int, 0, size) | |
| for i := 0; i < size; i++ { | |
| arr = append(arr, i) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func notUseAppend() { | |
| var arr = make([]int, 1, size) | |
| for k := range arr { | |
| arr[k] = k | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| var size = 10000 | |
| func useAppendWithoutLength() { | |
| var arr = []int{} | |
| for i := 0; i < size; i++ { | |
| arr = append(arr, i) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func BenchmarkTestWithLength(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| useAppendWithLength() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func BenchmarkTestWithoutLength(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| useAppendWithoutLength() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func BenchmarkTestNotUseAppend(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| notUseAppend() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "testing" | |
| func BenchmarkTestWithLength(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| useAppendWithLength() | |
| } | |
| } |
OlderNewer