From 3e3413566b45d795bd9227a60de85f40200b35a2 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Sun, 26 Feb 2017 12:57:38 +0100 Subject: [PATCH] Only do expensive area coverage calculation if there where blocks loaded from database. If there are not, nothing changed, so nothing to recalculate. Takes a good deal from the clock. --- cmd/mtseeder/main.go | 13 +++++++++++ cmd/mtwebmapper/web/index.html | 2 +- common/basetilecreator.go | 40 +++++++++++++++++++--------------- common/redisclient.go | 4 ++-- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/cmd/mtseeder/main.go b/cmd/mtseeder/main.go index 0cbb0f9..38396a6 100644 --- a/cmd/mtseeder/main.go +++ b/cmd/mtseeder/main.go @@ -8,6 +8,8 @@ import ( "flag" "fmt" "log" + "os" + "runtime/pprof" "bitbucket.org/s_l_teichmann/mtsatellite/common" ) @@ -27,6 +29,7 @@ func main() { transparent bool transparentDim float64 version bool + cpuProfile string ) defaultBgColor := common.ColorToHex(common.BackgroundColor) @@ -60,6 +63,7 @@ func main() { "td", common.DefaultTransparentDim*100.0, "Extra fimming of transparent nodes each depth meter in percent. (shorthand)") flag.BoolVar(&version, "version", false, "Print version and exit.") + flag.StringVar(&cpuProfile, "c", "", "Dump pprof profile to file.") flag.Parse() @@ -67,6 +71,15 @@ func main() { common.PrintVersionAndExit() } + if cpuProfile != "" { + f, err := os.Create(cpuProfile) + if err != nil { + log.Fatal(err) + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } + bg := common.ParseColorDefault(bgColor, common.BackgroundColor) if !skipBaseLevel { diff --git a/cmd/mtwebmapper/web/index.html b/cmd/mtwebmapper/web/index.html index 85345af..dd26a91 100644 --- a/cmd/mtwebmapper/web/index.html +++ b/cmd/mtwebmapper/web/index.html @@ -48,7 +48,7 @@