golang test测试使用
2015-03-05 14:23
357 查看
1.创建测试文件夹mysql,文件夹下的go文件的package必须与文件夹名一致(不然会识别不到)
2.创建需要测试的文件mysql.go(使用github.com/go-sql-driver/mysql包)
View Code
5.用性能测试生成CPU状态图(暂未测试使用)
2.创建需要测试的文件mysql.go(使用github.com/go-sql-driver/mysql包)
package mysql import ( "testing" ) func Benchmark_findByPk(b *testing.B) { for i := 0; i < b.N; i++ { //use b.N for looping findByPk(1) } }
View Code
进行所有go文件的benchmark测试 go test -bench=".*" 或 go test . -bench=".*"
对某个go文件进行benchmark测试 go test mysql_b_test.go -bench=".*"
测试单个文件时,找不到方法,似乎要引入文件吧(暂未测试)
5.用性能测试生成CPU状态图(暂未测试使用)
使用命令:
go test -bench=".*" -cpuprofile=cpu.prof -c
cpuprofile是表示生成的cpu profile文件
-c是生成可执行的二进制文件,这个是生成状态图必须的,它会在本目录下生成可执行文件mysql.test
然后使用go tool pprof工具
go tool pprof mysql.test cpu.prof
调用web(需要安装graphviz)来生成svg文件,生成后使用浏览器查看svg文件 参考 /article/4686583.html
相关文章推荐
- 使用 TestDriven.NET 实施『测试驱动开发』
- [原创]使用QuickTest Pro 进行测试流程
- 使用vs2010的Coded UI Test实现数据驱动的用户自动登录测试
- 如何使用kvm autotest来测试kernel
- 使用test命令进行进行条件测试
- 使用Application Center Test (ACT)来做压力测试
- 使用Robot Test Automation Framework来控制只支持TCL libary的测试设备
- 使用vs2010的Coded UI Test实现数据驱动的用户自动登录测试
- 噪点测试软件 DeadPixelTest 使用方法
- 在使用Microsoft Visual Studio Test Controller 2010进行测试时,报如下错误: System.DllNotFoundException: 无法加载 DLL“Microsoft.VisualStudio.QualityTools.RecorderBarBHO100.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。
- 在PB中如何使用软件测试工具rational teamtest
- 使用WCF Test Client(WcfTestClient.exe) 来测试WCF
- NUnit单元测试整理高级篇之测试数据库操作以及VS插件TestDriven的使用
- 使用XFire+Spring构建Web Service------测试工程在myeclipse的默认工作目录下的webservicetesthellworld
- [笔记].怎样使用Nios II中的Memory Test模板来测试RAM和Flash
- VSTS 编写测试Test技巧:如何使用Deployment Items在测试类中引用文件,和普通Windows项目不一样哦。
- 使用Windows Mobile Test Framework进行Windows Mobile程序的自动化测试
- 供智商超过180的人使用的测试卷:Haselbauer-Dickheiser Test
- 使用 TestApi 进行错误注入测试 (msdn)
- Ubuntu上使用autotest做Rails项目的自动测试 - autotest安装和测试