adds abilit to report timing for execution
This commit is contained in:
parent
cfc719dae3
commit
ff9cc1349f
@ -4,11 +4,14 @@ import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"text/template"
|
||||
)
|
||||
|
||||
func buildBindResponsePolicyFile() {
|
||||
defer timeTrack(time.Now(), "buildBindResponsePolicyFile")
|
||||
|
||||
var (
|
||||
output bytes.Buffer
|
||||
)
|
||||
|
@ -4,9 +4,12 @@ import (
|
||||
"log"
|
||||
"regexp"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
func cleanBadDomains(domains []string) []string {
|
||||
defer timeTrack(time.Now(), "cleanBadDomains")
|
||||
|
||||
// remove duplicates
|
||||
total := len(domains)
|
||||
all := make(map[string]bool)
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
)
|
||||
|
||||
func getListData() []string {
|
||||
defer timeTrack(time.Now(), "getListData")
|
||||
|
||||
var badDomains []string
|
||||
listSimple := make(chan []string)
|
||||
listComplex := make(chan []string)
|
||||
@ -59,6 +61,8 @@ func getListData() []string {
|
||||
}
|
||||
|
||||
func getData(urls []string) []byte {
|
||||
defer timeTrack(time.Now(), "getData")
|
||||
|
||||
var listData []byte
|
||||
|
||||
for _, u := range urls {
|
||||
|
@ -15,6 +15,8 @@ import (
|
||||
|
||||
// getEnvString returns string from environment variable
|
||||
func getEnvString(env, def string) (val string) { //nolint:deadcode
|
||||
defer timeTrack(time.Now(), "getEnvString")
|
||||
|
||||
val = os.Getenv(env)
|
||||
|
||||
if val == "" {
|
||||
@ -26,6 +28,8 @@ func getEnvString(env, def string) (val string) { //nolint:deadcode
|
||||
|
||||
// getEnvInt returns int from environment variable
|
||||
func getEnvInt(env string, def int) (ret int) {
|
||||
defer timeTrack(time.Now(), "getEnvInt")
|
||||
|
||||
val := os.Getenv(env)
|
||||
|
||||
if val == "" {
|
||||
@ -41,6 +45,8 @@ func getEnvInt(env string, def int) (ret int) {
|
||||
}
|
||||
|
||||
func initialize() {
|
||||
defer timeTrack(time.Now(), "initialize")
|
||||
|
||||
config.TimeZone, _ = time.LoadLocation("America/Chicago")
|
||||
config.TimeZoneUTC, _ = time.LoadLocation("UTC")
|
||||
|
||||
@ -189,6 +195,8 @@ func initialize() {
|
||||
}
|
||||
|
||||
func readConfigFile(configFileLocation string) (configFileStruct, error) {
|
||||
defer timeTrack(time.Now(), "readConfigFile")
|
||||
|
||||
var output configFileStruct
|
||||
|
||||
rd, err := ioutil.ReadFile(configFileLocation)
|
||||
|
@ -6,11 +6,14 @@ import (
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
)
|
||||
|
||||
func parseComplex(data []byte) []string {
|
||||
defer timeTrack(time.Now(), "parseComplex")
|
||||
|
||||
var domains []string
|
||||
|
||||
// convert data to reader for line-by-line reading
|
||||
|
@ -6,11 +6,14 @@ import (
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
)
|
||||
|
||||
func parseSimple(data []byte) []string {
|
||||
defer timeTrack(time.Now(), "parseSimple")
|
||||
|
||||
var domains []string
|
||||
|
||||
// convert data to reader for line-by-line reading
|
||||
|
11
cmd/bind/supporting-functions.go
Normal file
11
cmd/bind/supporting-functions.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func timeTrack(start time.Time, name string) {
|
||||
elapsed := time.Since(start)
|
||||
log.Printf("[TRACE] Function %s took %s\n", name, elapsed)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user