企业🤖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)) } ~~~ > ### 效果图 > ![](https://img.kancloud.cn/19/8c/198c073a9216902b3f65f237e0ff09ad_784x363.png) > ![](https://img.kancloud.cn/de/eb/deeb83afaf58e6d8530ecb0af3793212_962x259.png)