多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
> ### 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)) } ~~~ > ### 效果图 ![](https://img.kancloud.cn/8c/a1/8ca192a8aeec65b065877ce695241578_747x583.png) ![](https://img.kancloud.cn/18/87/18873dd703c56cbbc2b957ecf1898a61_945x290.png)