企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
> ### Heap信息采集 * 申请内存到heap ~~~ package main import ( "fmt" "math/rand" "os" "runtime/pprof" "time" ) func main() { file, err := os.Create("./heap.pprof") if err != nil { fmt.Println(err) } defer file.Close() defer pprof.WriteHeapProfile(file) for i := 0; i < 10; i++ { go actionSort() } time.Sleep(time.Second * 10) } func actionSort() { rand.Seed(time.Now().Unix()) number := make([]int, 30000, 10000000) for k, _ := range number { number[k] = rand.Intn(100) } L := len(number) BubbleSort(number, L) } func BubbleSort(data []int, L int) { t := time.Now() for i := 0; i < L; i++ { for j := i + 1; j < L; j++ { if data[i] > data[j] { data[i], data[j] = data[j], data[i] } } } fmt.Println("BubbleSort - Time:", time.Since(t)) } ~~~ > ### 效果图 ![](/D:/%E6%AD%A3%E5%BC%8F%E6%A1%8C%E9%9D%A2/Golang%E5%B7%A5%E4%BD%9C%E7%AC%94%E8%AE%B0/book/Golang%E5%B7%A5%E4%BD%9C%E7%AC%94%E8%AE%B0/images/QQ%E6%88%AA%E5%9B%BE20181031163543.jpg) ![](/D:/%E6%AD%A3%E5%BC%8F%E6%A1%8C%E9%9D%A2/Golang%E5%B7%A5%E4%BD%9C%E7%AC%94%E8%AE%B0/book/Golang%E5%B7%A5%E4%BD%9C%E7%AC%94%E8%AE%B0/images/QQ%E6%88%AA%E5%9B%BE20181031163633.jpg)