Skip to content

Instantly share code, notes, and snippets.

@dustinsmith1024
Created July 16, 2015 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinsmith1024/176280e3b705b0f1088a to your computer and use it in GitHub Desktop.
Save dustinsmith1024/176280e3b705b0f1088a to your computer and use it in GitHub Desktop.
Our Golang timing with logger
// for our internal time
saverTimer := logger.Timer()
var totalParseTime time.Duration
var totalTime time.Duration
for {
row, err := csvReader.ReadMap(false)
...
start := time.Now()
parseStart := time.Now()
record.TransactionDate, err = date.ParseDate(row["transaction_date"])
if err != nil {
return err
}
parseEnd := time.Now()
totalParseTime = totalParseTime + end.Sub(start)
...
end := time.Now()
totalTime = totalTime + end.Sub(start)
}
fmt.Println("total JSON duration", totalJSONParseTime)
fmt.Println("total duration", totalParseTime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment