Skip to content

Instantly share code, notes, and snippets.

@deven96
Created March 23, 2022 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deven96/a9c0ec876a3f6ee062e629b20d442708 to your computer and use it in GitHub Desktop.
Save deven96/a9c0ec876a3f6ee062e629b20d442708 to your computer and use it in GitHub Desktop.
profile me in golang
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