MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / BenchmarkHash

Function BenchmarkHash

hashing/sha256/sha256_test.go:29–48  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

27}
28
29func BenchmarkHash(b *testing.B) {
30 testCases := []struct {
31 name string
32 in string
33 }{
34 {"hello world", "hello world"},
35 {"empty", ""},
36 {"a", "a"},
37 {"The quick brown fox jumps over the lazy dog", "The quick brown fox jumps over the lazy dog"},
38 {"The quick brown fox jumps over the lazy dog.", "The quick brown fox jumps over the lazy dog."},
39 {"Lorem ipsum", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."},
40 }
41 for _, testCase := range testCases {
42 b.Run(testCase.name, func(b *testing.B) {
43 for i := 0; i < b.N; i++ {
44 Hash([]byte(testCase.in))
45 }
46 })
47 }
48}

Callers

nothing calls this directly

Calls 1

HashFunction · 0.70

Tested by

no test coverage detected