Skip to content

DirreckH/leetcode-withTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leetcode-withTest

说明

本仓库主要涉及少量leetcode作为学习使用,其中添加覆盖率测试表格测试性能测试,测试代码及输出内容均可查看。

使用方法

代码覆盖率测试

// 生成二进制文件
go test . -coverprofile=c.out
// 以网页形式查看
go tool cover -html=c.out

代码表格驱动测试

go test .

代码性能测试

// 可直接进行测试
go test -bench .
// 使用pprof工具
go test -bench . -cpuprofile=cpu.out
// 使用 go tool 打开
go tool pprof cpu.out
// 选择使用 web
(pprof) web

启动火焰图的方法:

import "net/http"
import _ "net/http/pprof"
func main() {
    // 主函数中添加
	http.ListenAndServe("0.0.0.0:9999", nil)
 
}

并且在命令行中输入:

go tool pprof -http=:6666 http://localhost:9999/debug/pprof/profile

等待30s左右后可以在浏览器中查看

About

leedcode学习&测试

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •