性能測試
go test -bench=.*
func BenchmarkQueryYellowPagesMessageWithStaff(b *testing.B) {
var yps YellowPagesStorage
// 獲得連接數(shù)據(jù)庫參數(shù)
mysqlUtility.DB_CONF = getDbConfig()
// 打開數(shù)據(jù)庫連接
mysqlUtility.DBConn = mysqlUtility.ConnectToDB()
// alog初始化
// alog.RegisterAlog("../../apps/web/conf/config.yaml")
// alog.SetLogTag("XG")
// 測試方法
for i := 0; i < b.N; i++ {
yps.QueryYellowPagesMessageWithStaff("測", 1, 1)
}
// 關(guān)閉數(shù)據(jù)庫連接
mysqlUtility.DBConn.Close()
}
HaoCdeMacBook-Pro:apiphone haoc$ go test -bench=.*
2017/03/31 16:38:01 [I] 數(shù)據(jù)庫初始化成功...
2017/03/31 16:38:01 [I] 數(shù)據(jù)庫初始化成功...
BenchmarkQueryYellowPagesMessageWithStaff-8 2017/03/31 16:38:02 [I] 數(shù)據(jù)庫初始化成功...
2 560568385 ns/op
PASS
ok AntLinkCampus/CampusServer/storage/apiphone 2.413s
測試單個方法
go test -v -test.run TestQueryYellowPagesMessageWithStaff
func TestQueryYellowPagesMessageWithStaff(t *testing.T) {
var yps YellowPagesStorage
// 獲得數(shù)據(jù)庫連接參數(shù)
mysqlUtility.DB_CONF = getDbConfig()
// 打開數(shù)據(jù)庫連接
mysqlUtility.DBConn = mysqlUtility.ConnectToDB()
// alog初始化
alog.RegisterAlog("../../apps/web/conf/config.yaml")
alog.SetLogTag("XG")
// 測試方法
yps.QueryYellowPagesMessageWithStaff("測", 1, 1)
// 關(guān)閉數(shù)據(jù)庫連接
mysqlUtility.DBConn.Close()
}
HaoCdeMacBook-Pro:apiphone haoc$ go test -v -test.run TestQueryYellowPagesMessageWithStaff
=== RUN TestQueryYellowPagesMessageWithStaff
2017/03/31 16:42:14 [I] 數(shù)據(jù)庫初始化成功...
--- PASS: TestQueryYellowPagesMessageWithStaff (0.57s)
PASS
ok AntLinkCampus/CampusServer/storage/apiphone 0.580s
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者