Created
March 23, 2022 12:40
-
-
Save deven96/a9c0ec876a3f6ee062e629b20d442708 to your computer and use it in GitHub Desktop.
profile me in golang
This file contains 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 ( | |
"math" | |
"github.com/pkg/profile" | |
) | |
func makeArray(num int, size float64) []int { | |
arr := make([]int, int(size)) | |
for ind := range arr { | |
arr[ind] = num | |
} | |
return arr | |
} | |
func myFunc() []int { | |
a := makeArray(1, math.Pow(10, 6)) | |
b := makeArray(2, 2*math.Pow(10, 7)) | |
return append(a, b[200000]) | |
} | |
func main() { | |
defer profile.Start(profile.MemProfile).Stop() | |
myFunc() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment