Skip to content

Commit

Permalink
fixed duration summary
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Jan 26, 2018
1 parent 30446b9 commit 79d9c3c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions commands/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ func (t *Templating) Run() (err error) {

err = t.unpackTemplate(tpl.Url, tempDir)

endTimeClone := time.Since(startTimeClone).Seconds()

defer func() {
r := recover()
if err != nil || r != nil {
Expand Down Expand Up @@ -700,6 +702,8 @@ func (t *Templating) Run() (err error) {
t.stop()
templatingSpinner.Stop()

endTimeTemplating := time.Since(startTimeTemplating).Seconds()

startTimeHooks := time.Now()

if t.surveyResult != nil {
Expand All @@ -713,6 +717,8 @@ func (t *Templating) Run() (err error) {
logy.Debug("skip template hooks")
}

endTimeHooks := time.Since(startTimeHooks).Seconds()

confirmed, err := t.confirmPackTemplate()
if confirmed {
err = t.packTemplate(tempDir, t.CommandData.Path)
Expand Down Expand Up @@ -744,14 +750,11 @@ func (t *Templating) Run() (err error) {
}

// print summary
totalCloneDuration := time.Since(startTimeClone).Seconds()
totalTemplatingDuration := time.Since(startTimeTemplating).Seconds()
totalHooksDuration := time.Since(startTimeHooks).Seconds()
totalDuration := totalCloneDuration + totalTemplatingDuration + totalHooksDuration
totalDuration := endTimeClone + endTimeTemplating + endTimeHooks
fmt.Printf("\nClone: %s sec \nTemplating: %s sec\nHooks: %s\nTotal: %s sec",
strconv.FormatFloat(totalCloneDuration, 'f', 2, 64),
strconv.FormatFloat(totalTemplatingDuration, 'f', 2, 64),
strconv.FormatFloat(totalHooksDuration, 'f', 2, 64),
strconv.FormatFloat(endTimeClone, 'f', 2, 64),
strconv.FormatFloat(endTimeTemplating, 'f', 2, 64),
strconv.FormatFloat(endTimeHooks, 'f', 2, 64),
strconv.FormatFloat(totalDuration, 'f', 2, 64),
)

Expand Down

0 comments on commit 79d9c3c

Please sign in to comment.