Fix benchmarktests (#557)

This commit is contained in:
Kjell Kvinge 2017-01-03 03:52:09 +01:00 提交者 Lunny Xiao
父節點 7be02d9020
當前提交 4b0974ec10
共有 1 個檔案被更改,包括 16 行新增12 行删除

查看文件

@ -17,25 +17,29 @@ func BenchmarkGetCommitGraph(b *testing.B) {
b.Error("Could not open repository")
}
graph, err := GetCommitGraph(currentRepo)
if err != nil {
b.Error("Could get commit graph")
}
for i := 0; i < b.N; i++ {
graph, err := GetCommitGraph(currentRepo)
if err != nil {
b.Error("Could get commit graph")
}
if len(graph) < 100 {
b.Error("Should get 100 log lines.")
if len(graph) < 100 {
b.Error("Should get 100 log lines.")
}
}
}
func BenchmarkParseCommitString(b *testing.B) {
testString := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Kjell Kvinge|kjell@kvinge.biz|4e61bac|Add route for graph"
graphItem, err := graphItemFromString(testString, nil)
if err != nil {
b.Error("could not parse teststring")
}
for i := 0; i < b.N; i++ {
graphItem, err := graphItemFromString(testString, nil)
if err != nil {
b.Error("could not parse teststring")
}
if graphItem.Author != "Kjell Kvinge" {
b.Error("Did not get expected data")
if graphItem.Author != "Kjell Kvinge" {
b.Error("Did not get expected data")
}
}
}