zoukankan      html  css  js  c++  java
  • golang可视化

    golang 可视化调试

    package main
    
    import (
    	"fmt"
    	"os"
    	"runtime/trace"
    )
    
    func main()  {
    	// 创建trace
    	f,err := os.Create("trace.out")
    	if err != nil{
    		panic(err)
    	}
    
    	defer f.Close()
    
    	// 启动trace
    	err = trace.Start(f)
    	if err != nil {
    		panic(err)
    	}
    	fmt.Println("hello GMP")
    	// 停止trace
    	trace.Stop()
    }
    

    执行命令

     go tool trace trace.out  
    

    点击 view trace

    debug查看

    GODEBUG-schedtrace=1000 ./main 
    
    package main
    
    import (
    	"fmt"
    	"time"
    )
    
    func main() {
    	for i:=0;i<5;i++{
    		fmt.Println(i)
    		time.Sleep(time.Second)
    	}
    }
    
    
    ╭─deepin@deepin-PC ~/go/test1 
    ╰─$ GODEBUG=schedtrace=1000 ./main
    SCHED 0ms: gomaxprocs=6 idleprocs=3 threads=5 spinningthreads=1 idlethreads=0 runqueue=0 [0 0 0 0 0 0]
    0
    1
    SCHED 1002ms: gomaxprocs=6 idleprocs=6 threads=5 spinningthreads=0 idlethreads=3 runqueue=0 [0 0 0 0 0 0]
    2
    SCHED 2009ms: gomaxprocs=6 idleprocs=6 threads=5 spinningthreads=0 idlethreads=3 runqueue=0 [0 0 0 0 0 0]
    3
    SCHED 3016ms: gomaxprocs=6 idleprocs=6 threads=5 spinningthreads=0 idlethreads=3 runqueue=0 [0 0 0 0 0 0]
    4
    SCHED 4022ms: gomaxprocs=6 idleprocs=6 threads=5 spinningthreads=0 idlethreads=3 runqueue=0 [0 0 0 0 0 0]
    
    
  • 相关阅读:
    Debian ABC --- 1st time ---7
    django基础操作
    http协议
    css3种引入方式,样式与长度颜色,常用样式,css选择器
    前端3剑客
    视图,sql注入问题,事物,存储过程
    用户权限,pymysql
    表查询
    约束
    mysql数据类型
  • 原文地址:https://www.cnblogs.com/brady-wang/p/15179121.html
Copyright © 2011-2022 走看看