From 94f5a72e2686c1946f2a76070b6fc8ff365d28a1 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 6 Sep 2016 12:52:11 +0100 Subject: [PATCH] Add debugging option to codebase --- main.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 2a6a9f99..c05626c2 100644 --- a/main.go +++ b/main.go @@ -14,8 +14,27 @@ package main -import "github.com/abcum/surreal/cli" +import ( + "os" + + "github.com/pkg/profile" + + "github.com/abcum/surreal/cli" +) func main() { + + switch os.Getenv("DEBUG") { + case "cpu": + defer profile.Start(profile.CPUProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() + case "mem": + defer profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() + case "block": + defer profile.Start(profile.BlockProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() + case "trace": + defer profile.Start(profile.TraceProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() + } + cli.Init() + }