From 7e06004e796a8a3e80b5633f8bec60ca3243d712 Mon Sep 17 00:00:00 2001 From: Nathan Lowe Date: Wed, 19 Dec 2018 16:13:33 -0500 Subject: [PATCH] Only profile if asked --- aoc2018.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aoc2018.go b/aoc2018.go index 3ca16b2..d98d86e 100644 --- a/aoc2018.go +++ b/aoc2018.go @@ -45,10 +45,14 @@ var rootCmd = &cobra.Command{ } start = time.Now() - profiler = profile.Start() + if viper.GetBool("profile") { + profiler = profile.Start() + } }, PersistentPostRun: func(_ *cobra.Command, _ []string) { - profiler.Stop() + if profiler != nil { + profiler.Stop() + } fmt.Printf("Took %s\n", time.Since(start)) }, }