DNS Benchmarking Tool
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

main.go 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/schollz/progressbar"
  5. "gopkg.in/alecthomas/kingpin.v2"
  6. )
  7. var (
  8. numRequests = kingpin.Flag("i", "Number of Requests per DNS server").Default("1000").Short('i').Uint16()
  9. wildcardEndpoint = kingpin.Flag("e", "DNS Wildcard Endpoint to benchmark against").Default("google.com").Short('e').String()
  10. dnsServers = kingpin.Arg("dns servers", "DNS Servers to ping").Default("127.0.0.1", "8.8.8.8").Strings()
  11. sleepTimeout = kingpin.Flag("wait-request", "Time to wait between requests in milliseconds").Default("100").Uint()
  12. antiCache = kingpin.Flag("anti-cache", "Prepend randomized subdomains to query to prevent some caching. THIS REQUIRES A WILDCARD DNS ENTRY!").Default("false").Bool()
  13. errorTolerance = kingpin.Flag("error-tolerance", "Number of errors that may occur per server before the test is aborted").Short('z').Default("80").Int()
  14. )
  15. func main() {
  16. kingpin.Parse()
  17. for k := range *dnsServers {
  18. fmt.Printf("Testing %s...\n", (*dnsServers)[k])
  19. bar := progressbar.New(int(*numRequests))
  20. res, err := bench((*dnsServers)[k], *wildcardEndpoint, *numRequests, func(i, _ uint16) {
  21. bar.Set(int(i))
  22. })
  23. if err != nil {
  24. fmt.Printf("\nError: %s\n", err)
  25. return
  26. }
  27. bar.Show()
  28. fmt.Printf("\n"+
  29. "\tP00.5 = % 6.3fms\n"+
  30. "\tP05.0 = % 6.3fms\n"+
  31. "\tP25.0 = % 6.3fms\n"+
  32. "\tP50.0 = % 6.3fms\n"+
  33. "\tP75.0 = % 6.3fms\n"+
  34. "\tP95.0 = % 6.3fms\n"+
  35. "\tP99.5 = % 6.3fms\n"+
  36. "\tAVG = % 6.3fms\n"+
  37. "\tDNSSEC = % 6t\n",
  38. res.TimeResults.P0Dot5.Seconds()*1000,
  39. res.TimeResults.P5.Seconds()*1000,
  40. res.TimeResults.P25.Seconds()*1000,
  41. res.TimeResults.P50.Seconds()*1000,
  42. res.TimeResults.P75.Seconds()*1000,
  43. res.TimeResults.P95.Seconds()*1000,
  44. res.TimeResults.P99Dot5.Seconds()*1000,
  45. res.TimeResults.Average.Seconds()*1000,
  46. res.DNSSECSupport,
  47. )
  48. fmt.Println("")
  49. }
  50. }