Add tailscale checksum
This commit is contained in:
parent
4ebeb2fa86
commit
06b4d4ecd1
11 changed files with 2254 additions and 28 deletions
33
internal/checksum_test/sum_bench_test.go
Normal file
33
internal/checksum_test/sum_bench_test.go
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue