good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 14172e5b authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Benchmark pure go masking algorithm separately from assembly

parent f5397ae3
Branches
Tags
No related merge requests found
...@@ -26,6 +26,9 @@ func gorillaMaskBytes(key [4]byte, pos int, b []byte) int ...@@ -26,6 +26,9 @@ func gorillaMaskBytes(key [4]byte, pos int, b []byte) int
//go:linkname mask nhooyr.io/websocket.mask //go:linkname mask nhooyr.io/websocket.mask
func mask(key32 uint32, b []byte) int func mask(key32 uint32, b []byte) int
//go:linkname maskGo nhooyr.io/websocket.maskGo
func maskGo(key32 uint32, b []byte) int
func Benchmark_mask(b *testing.B) { func Benchmark_mask(b *testing.B) {
sizes := []int{ sizes := []int{
2, 2,
...@@ -54,7 +57,18 @@ func Benchmark_mask(b *testing.B) { ...@@ -54,7 +57,18 @@ func Benchmark_mask(b *testing.B) {
}, },
{ {
name: "nhooyr", name: "nhooyr-go",
fn: func(b *testing.B, key [4]byte, p []byte) {
key32 := binary.LittleEndian.Uint32(key[:])
b.ResetTimer()
for i := 0; i < b.N; i++ {
maskGo(key32, p)
}
},
},
{
name: "wdvxdr1123-asm",
fn: func(b *testing.B, key [4]byte, p []byte) { fn: func(b *testing.B, key [4]byte, p []byte) {
key32 := binary.LittleEndian.Uint32(key[:]) key32 := binary.LittleEndian.Uint32(key[:])
b.ResetTimer() b.ResetTimer()
...@@ -64,6 +78,7 @@ func Benchmark_mask(b *testing.B) { ...@@ -64,6 +78,7 @@ func Benchmark_mask(b *testing.B) {
} }
}, },
}, },
{ {
name: "gorilla", name: "gorilla",
fn: func(b *testing.B, key [4]byte, p []byte) { fn: func(b *testing.B, key [4]byte, p []byte) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment