Open thaJeztah opened 3 weeks ago
No need to validate the format if we previously accepted it to be registered.
Just for convenience ':-)
Before:
pkg: github.com/opencontainers/go-digest/digestset BenchmarkAdd10-10 183613 6368 ns/op BenchmarkAdd100-10 15739 75741 ns/op BenchmarkAdd1000-10 1430 831884 ns/op BenchmarkRemove10-10 169999 6984 ns/op BenchmarkRemove100-10 15312 78299 ns/op BenchmarkRemove1000-10 1470 815144 ns/op BenchmarkLookup10-10 27067897 43.69 ns/op BenchmarkLookup100-10 17203653 69.17 ns/op BenchmarkLookup1000-10 13043708 96.32 ns/op BenchmarkShortCode10-10 3574094 334.5 ns/op BenchmarkShortCode100-10 320438 3782 ns/op BenchmarkShortCode1000-10 29110 41460 ns/op
After:
pkg: github.com/opencontainers/go-digest/digestset BenchmarkAdd10 BenchmarkAdd10-10 176776 6400 ns/op 608 B/op 12 allocs/op BenchmarkAdd100-10 15267 76016 ns/op 5746 B/op 102 allocs/op BenchmarkAdd1000-10 1426 833977 ns/op 56267 B/op 1002 allocs/op BenchmarkRemove10-10 169448 7043 ns/op 128 B/op 2 allocs/op BenchmarkRemove100-10 15249 78730 ns/op 944 B/op 2 allocs/op BenchmarkRemove1000-10 1444 819247 ns/op 8240 B/op 2 allocs/op BenchmarkLookup10-10 27042379 45.68 ns/op 0 B/op 0 allocs/op BenchmarkLookup100-10 17098725 69.72 ns/op 0 B/op 0 allocs/op BenchmarkLookup1000-10 12769602 92.97 ns/op 0 B/op 0 allocs/op BenchmarkShortCode10-10 3551202 332.1 ns/op 630 B/op 2 allocs/op BenchmarkShortCode100-10 313929 3805 ns/op 5449 B/op 4 allocs/op BenchmarkShortCode1000-10 28963 41373 ns/op 81992 B/op 3 allocs/op
Remove fmt.Sprintf and use string-concatenation instead to reduce some allocations.
Before / After:
BenchmarkNewDigestFromEncoded-10 8474174 128.4 ns/op 112 B/op 3 allocs/op BenchmarkNewDigestFromEncoded-10 37912695 31.55 ns/op 80 B/op 1 allocs/op BenchmarkNewDigestFromBytes-10 5087299 237.2 ns/op 200 B/op 5 allocs/op BenchmarkNewDigestFromBytes-10 8416543 146.8 ns/op 168 B/op 3 allocs/op
address some linting issues
testdigest: fix package GoDoc to be in the right format
remove import aliases
RegisterAlgorithm: skip regex if not needed
No need to validate the format if we previously accepted it to be registered.
use errors.New() for errors that don't need formatting
digestset: report allocations in benchmarks
Just for convenience ':-)
Before:
After:
remove unneeded fmt.Sprintf and indirections
Remove fmt.Sprintf and use string-concatenation instead to reduce some allocations.
Before / After: