time.go 396 B

12345678910111213141516
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package helper
  5. import (
  6. "log"
  7. "time"
  8. )
  9. // ExecutionTime returns the elapsed time of a block of code.
  10. func ExecutionTime(start time.Time, name string) {
  11. elapsed := time.Since(start)
  12. log.Printf("%s took %s", name, elapsed)
  13. }