Skip to content

Commit

Permalink
Merge pull request #44 from ipfs/feat/bench
Browse files Browse the repository at this point in the history
add String benchmark
  • Loading branch information
Stebalien committed Aug 10, 2018
2 parents 5eff744 + d6e0b4e commit 1543f4a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,17 @@ func TestJsonRoundTrip(t *testing.T) {
t.Fatal("cids not equal for Cid")
}
}

func BenchmarkStringV1(b *testing.B) {
data := []byte("this is some test content")
hash, _ := mh.Sum(data, mh.SHA2_256, -1)
cid := NewCidV1(Raw, hash)
b.ResetTimer()
count := 0
for i := 0; i < b.N; i++ {
count += len(cid.String())
}
if count != 49*b.N {
b.FailNow()
}
}

0 comments on commit 1543f4a

Please sign in to comment.