ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
> ### CPU信息采集 ~~~ package main import ( "fmt" "math/rand" "os" "runtime/pprof" "time" ) func main() { file, err := os.Create("./cpu.pprof") if err != nil { fmt.Println(err) } pprof.StartCPUProfile(file) defer file.Close() defer pprof.StopCPUProfile() 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%BE20181031161947.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%BE20181031162113.jpg)