more testing and concurrent server benchmarking

This commit is contained in:
Miek Gieben 2013-06-22 08:55:30 +01:00
parent 9762efef1e
commit 5ae9b5214f
3 changed files with 8 additions and 2 deletions

View File

@ -108,6 +108,8 @@ func (rr *OPT) copy() RR {
return &OPT{*rr.Hdr.copyHeader(), rr.Option} return &OPT{*rr.Hdr.copyHeader(), rr.Option}
} }
// return the old value -> delete SetVersion
// Version returns the EDNS version used. Only zero is defined. // Version returns the EDNS version used. Only zero is defined.
func (rr *OPT) Version() uint8 { func (rr *OPT) Version() uint8 {
return uint8(rr.Hdr.Ttl & 0x00FF00FFFF) return uint8(rr.Hdr.Ttl & 0x00FF00FFFF)

View File

@ -371,7 +371,8 @@ func TestParseFailure(t *testing.T) {
} }
} }
// A bit useless, how to use b.N? /*
// A bit useless, how to use b.N?. It always returns 0
func BenchmarkZoneParsing(b *testing.B) { func BenchmarkZoneParsing(b *testing.B) {
b.StopTimer() b.StopTimer()
f, err := os.Open("t/miek.nl.signed_test") f, err := os.Open("t/miek.nl.signed_test")
@ -386,6 +387,7 @@ func BenchmarkZoneParsing(b *testing.B) {
} }
} }
} }
*/
func TestZoneParsing(t *testing.T) { func TestZoneParsing(t *testing.T) {
f, err := os.Open("t/miek.nl.signed_test") f, err := os.Open("t/miek.nl.signed_test")

View File

@ -5,6 +5,7 @@
package dns package dns
import ( import (
"runtime"
"testing" "testing"
"time" "time"
) )
@ -59,8 +60,8 @@ func TestServing(t *testing.T) {
func BenchmarkServing(b *testing.B) { func BenchmarkServing(b *testing.B) {
b.StopTimer() b.StopTimer()
// Again start a server
HandleFunc("miek.nl.", HelloServer) HandleFunc("miek.nl.", HelloServer)
a := runtime.GOMAXPROCS(4)
go func() { go func() {
ListenAndServe("127.0.0.1:8053", "udp", nil) ListenAndServe("127.0.0.1:8053", "udp", nil)
}() }()
@ -73,6 +74,7 @@ func BenchmarkServing(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
c.Exchange(m, "127.0.0.1:8053") c.Exchange(m, "127.0.0.1:8053")
} }
runtime.GOMAXPROCS(a)
} }
func TestDotAsCatchAllWildcard(t *testing.T) { func TestDotAsCatchAllWildcard(t *testing.T) {