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

Add Memset() #9

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Add Memset() #9

merged 1 commit into from
Jul 22, 2024

Conversation

Jille
Copy link
Collaborator

@Jille Jille commented Jul 22, 2024

10x faster than a naive loop

$ go test -bench=Memset
goos: linux
goarch: amd64
pkg: github.com/bwesterb/go-and
cpu: 13th Gen Intel(R) Core(TM) i9-13900
BenchmarkMemset-32           	   73898	     15965 ns/op	62637.75 MB/s
BenchmarkMemsetGeneric-32    	    6602	    168255 ns/op	5943.36 MB/s

10x faster than a naive loop

```
$ go test -bench=Memset
goos: linux
goarch: amd64
pkg: github.com/bwesterb/go-and
cpu: 13th Gen Intel(R) Core(TM) i9-13900
BenchmarkMemset-32           	   73898	     15965 ns/op	62637.75 MB/s
BenchmarkMemsetGeneric-32    	    6602	    168255 ns/op	5943.36 MB/s
```

func memsetGeneric(dst []byte, b byte) {
for i := range dst {
dst[i] = b
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least we should write uint64 at a time.

@bwesterb bwesterb merged commit 9bb56b8 into bwesterb:main Jul 22, 2024
1 check passed
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.

2 participants