Skip to content

Commit

Permalink
test: Add tailscale checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Nov 22, 2024
1 parent cacaf7a commit cfd6979
Show file tree
Hide file tree
Showing 7 changed files with 2,230 additions and 0 deletions.
33 changes: 33 additions & 0 deletions internal/checksum_test/sum_bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package checksum_test

import (
"crypto/rand"
"testing"

"github.com/sagernet/sing-tun/internal/gtcpip/checksum"
"github.com/sagernet/sing-tun/internal/tschecksum"
)

func BenchmarkTsChecksum(b *testing.B) {
packet := make([][]byte, 1000)
for i := 0; i < 1000; i++ {
packet[i] = make([]byte, 1500)
rand.Read(packet[i])
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
tschecksum.Checksum(packet[i%1000], 0)
}
}

func BenchmarkGChecksum(b *testing.B) {
packet := make([][]byte, 1000)
for i := 0; i < 1000; i++ {
packet[i] = make([]byte, 1500)
rand.Read(packet[i])
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
checksum.Checksum(packet[i%1000], 0)
}
}
Loading

0 comments on commit cfd6979

Please sign in to comment.