]> source.dussan.org Git - gitea.git/commitdiff
Fix benchmarktests (#557)
authorKjell Kvinge <kjell@kvinge.biz>
Tue, 3 Jan 2017 02:52:09 +0000 (03:52 +0100)
committerLunny Xiao <xiaolunwen@gmail.com>
Tue, 3 Jan 2017 02:52:09 +0000 (10:52 +0800)
models/graph_test.go

index 23d8aa8492e789e6151b9596540e669652062c90..47c9dbb084ddb57a0b02f8a04da8d7a2f3b61ca1 100644 (file)
@@ -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")
-       }
-
-       if len(graph) < 100 {
-               b.Error("Should get 100 log lines.")
+       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.")
+               }
        }
 }
 
 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")
+               }
        }
 }