diff --git a/_examples/Makefile b/_examples/Makefile index 6f56a017..5e3548e9 100644 --- a/_examples/Makefile +++ b/_examples/Makefile @@ -4,7 +4,6 @@ key2ds \ axfr \ reflect \ q \ -qperf \ funkensturm \ diff --git a/_examples/qperf/Makefile b/_examples/qperf/Makefile deleted file mode 100644 index f5159b3f..00000000 --- a/_examples/qperf/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2009 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. -include $(GOROOT)/src/Make.inc -TARG=qperf -GOFILES=qperf.go -DEPS=../../ -include $(GOROOT)/src/Make.cmd diff --git a/_examples/qperf/qperf.go b/_examples/qperf/qperf.go deleted file mode 100644 index 5f096e64..00000000 --- a/_examples/qperf/qperf.go +++ /dev/null @@ -1,101 +0,0 @@ -package main - -import ( - "dns" - "flag" - "fmt" - "log" - "os" - "os/signal" - "runtime" - "runtime/pprof" - "time" -) - -func main() { - queries := flag.Int("queries", 20, "number of concurrent queries to perform") - maxproc := flag.Int("maxproc", 4, "set GOMAXPROCS to this value") - looptime := flag.Int("time", 2, "number of seconds to query") - reflect := flag.Bool("reflect", false, "enable reflection") - tcp := flag.Bool("tcp", false, "use tcp") - nameserver := flag.String("ns", "127.0.0.1:53", "the nameserver to query") - cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file") - qname := flag.String("qname", "miek.nl", "which qname to use") - - flag.Usage = func() { - flag.PrintDefaults() - } - queries_send := int64(0) - qid := uint16(1) - qtype := dns.TypeMX - qclass := uint16(dns.ClassINET) // Default qclass - flag.Parse() - if *cpuprofile != "" { - f, err := os.Create(*cpuprofile) - if err != nil { - log.Fatal(err) - } - pprof.StartCPUProfile(f) - defer pprof.StopCPUProfile() - } - runtime.GOMAXPROCS(*maxproc) - start := time.Nanoseconds() - fmt.Printf("Starting %d query functions. GOMAXPROCS set to %d. *reflection set to %v* [tcp = %v]\n", *queries, *maxproc, *reflect, *tcp) - fmt.Printf("Querying %s\n", *nameserver) - for i := 0; i < *queries; i++ { - go func() { - pktbuf := make([]byte, dns.DefaultMsgSize) - m := new(dns.Msg) - m.Question = make([]dns.Question, 1) - m.Question[0] = dns.Question{*qname, qtype, qclass} - qbuf, _ := m.Pack() - c := dns.NewClient() - if *tcp { - c.Net = "tcp" - } - - /* - if !*tcp { - // For UDP give each goroutine a socket. - // With TCP we re-dial every time - - if err := c.Dial(*nameserver); err != nil { - return - } - defer c.Close() - } - */ - - r := new(dns.Msg) - for { - // set Id - dns.RawSetId(qbuf, 0, qid) - n, err := c.ExchangeBuffer(qbuf, *nameserver, pktbuf) - if err != nil { - log.Print(err) - break // something went wrong - } - if *reflect { - r.Unpack(pktbuf[:n]) - // println(r.String()) - } - queries_send++ - qid++ - } - }() - } - - t := time.NewTicker(int64(*looptime) * 1e9) -wait: - for { - select { - case <-signal.Incoming: - log.Printf("Signal received, stopping") - break wait - case <-t.C: - break wait - } - } - delta := float32(time.Nanoseconds()-start) / 1e9 - fmt.Printf("%d queries in %.4f s (%.4f qps)\n", queries_send, delta, float32(queries_send)/delta) -}