Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BenchmarkHash function, the parameter h is changed from maphash to *maphash.Hash #8

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

Montana
Copy link

@Montana Montana commented May 16, 2024

In the benchmarkHash function, the parameter h is changed from maphash.Hash to *maphash.Hash. This is because maphash.Hash is a struct, not an interface, and should be passed as a pointer.

It should also be noted in the benchmarkHashn function, the size of the sum slice was set to 4, which may not be sufficient for all hash implementations. Instead, it should use h.Size() to determine the appropriate size based on the hash implementation.

func BenchmarkMaphash(b *testing.B) {
    var h maphash.Hash
    benchmarkHash(b, "maphash", h)
}

The blame is below:

https://github.com/redpanda-data/tinygo/blame/b8498403dd57cdf373280f663d67ffb5bb7eae44/tests/runtime/memhash_test.go#L11

In the BenchmarkMaphash function, when calling benchmarkHash, the & operator is added before h to pass the address of h instead of the value.

func benchmarkHash(b *testing.B, str string, h maphash.Hash) {
    // ...
}

The blame is below:

https://github.com/redpanda-data/tinygo/blame/b8498403dd57cdf373280f663d67ffb5bb7eae44/tests/runtime/memhash_test.go#L15

Cheers,
Michael Mendy

…Hash` to `*maphash.Hash`

In the `benchmarkHash` function, the parameter `h` is changed from `maphash.Hash` to `*maphash.Hash`. This is because `maphash.Hash` is a struct, not an interface, and should be passed as a pointer.

In the `BenchmarkMaphash` function, when calling `benchmarkHash`, the `&` operator is added before `h` to pass the address of `h` instead of the value.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Montana Montana changed the title BenchmarkHash function, the parameter h is changed from maphashHash to *maphash.Hash BenchmarkHash function, the parameter h is changed from maphash to *maphash.Hash May 16, 2024
@rockwotj
Copy link

Hi @Montana - you probably want to file this upstream at tinygo-org/tinygo 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants