Closed masih closed 2 years ago
Benchmark existing ways to check for IDENTITY CIDs
IDENTITY
Add benchmarks that compare two ways of checking for multihash.IDENTITY code:
multihash.IDENTITY
Cid.Prefix().MhType
Cid.Hash()
This benchmark illustrates that using Cid.Prefix is more efficient than multihash.Decode. Users wishing to perform such a check should use Cid.Prefix.
multihash.Decode
Cid.Prefix
Consider that Cid.Prefix is already efficient enough and introducing a dedicated API for performing this check will likely result in small gains.
BenchmarkIdentityCheck BenchmarkIdentityCheck/Prefix BenchmarkIdentityCheck/Prefix-8 351656472 3.280 ns/op BenchmarkIdentityCheck/MultihashDecode BenchmarkIdentityCheck/MultihashDecode-8 5715622 239.1 ns/op
Relates to #133
Will do 🍻
Context captured here
TLDR; there are multiple ways of inferring if a CID is IDENTITY and one of them is more efficient. The one that's more efficient is efficient enough to avoid the need to implement new APIs to do this (see closed PR for more details)
Benchmark existing ways to check for
IDENTITY
CIDsAdd benchmarks that compare two ways of checking for
multihash.IDENTITY
code:Cid.Prefix().MhType
Cid.Hash()
This benchmark illustrates that using Cid.Prefix is more efficient than
multihash.Decode
. Users wishing to perform such a check should useCid.Prefix
.Consider that
Cid.Prefix
is already efficient enough and introducing a dedicated API for performing this check will likely result in small gains.Relates to #133