Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

Commit

Permalink
Use b.Fatal in benchmark tests (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig authored and lunny committed May 27, 2017
1 parent ec4446b commit 56f6a2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ THE SOFTWARE.`

func Benchmark_Blob_Data(b *testing.B) {
for i := 0; i < b.N; i++ {
r, _ := testBlob.Data()
r, err := testBlob.Data()
if err != nil {
b.Fatal(err)
}
ioutil.ReadAll(r)
}
}
Expand All @@ -60,6 +63,8 @@ func Benchmark_Blob_DataPipeline(b *testing.B) {
stdout := new(bytes.Buffer)
for i := 0; i < b.N; i++ {
stdout.Reset()
testBlob.DataPipeline(stdout, nil)
if err := testBlob.DataPipeline(stdout, nil); err != nil {
b.Fatal(err)
}
}
}
10 changes: 5 additions & 5 deletions tree_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ func BenchmarkEntries_GetCommitsInfo(b *testing.B) {
var commit *Commit
var entries Entries
if repoPath, err := setupGitRepo(benchmark.url, benchmark.name); err != nil {
panic(err)
b.Fatal(err)
} else if repo, err := OpenRepository(repoPath); err != nil {
panic(err)
b.Fatal(err)
} else if commit, err = repo.GetBranchCommit("master"); err != nil {
panic(err)
b.Fatal(err)
} else if entries, err = commit.Tree.ListEntries(); err != nil {
panic(err)
b.Fatal(err)
}
entries.Sort()
b.StartTimer()
b.Run(benchmark.name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := entries.GetCommitsInfo(commit, "")
if err != nil {
panic(err)
b.Fatal(err)
}
}
})
Expand Down

0 comments on commit 56f6a2c

Please sign in to comment.