mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-22 16:13:31 +01:00
32 lines
545 B
Go
32 lines
545 B
Go
package peer
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
// FQDNOld is the original implementation for benchmarking purposes
|
|
func (p *Peer) FQDNOld(dnsDomain string) string {
|
|
if dnsDomain == "" {
|
|
return ""
|
|
}
|
|
return fmt.Sprintf("%s.%s", p.DNSLabel, dnsDomain)
|
|
}
|
|
|
|
func BenchmarkFQDN(b *testing.B) {
|
|
p := &Peer{DNSLabel: "test-peer"}
|
|
dnsDomain := "example.com"
|
|
|
|
b.Run("Old", func(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
p.FQDNOld(dnsDomain)
|
|
}
|
|
})
|
|
|
|
b.Run("New", func(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
p.FQDN(dnsDomain)
|
|
}
|
|
})
|
|
}
|