-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfig_dev.go
54 lines (47 loc) · 1.13 KB
/
config_dev.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// +build !release
package main
import (
"flag"
"github.com/ArchRobison/Gophetica/nimble"
"os"
"runtime/pprof"
)
const devConfig = true
var benchmarking = false
var fourierFrameCount = 0 // Number of fourier frames rendered
func tallyFourierFrame() {
if benchmarking {
if fourierFrameCount++; fourierFrameCount >= 1000 {
nimble.Quit()
}
}
}
// profileStart starts any profiling requested on the command line.
// It returns a slice of functions to be executed when main exits.
func profileStart() []func() {
fun := make([]func(), 0, 2)
cpuProfile := flag.String("cpuprofile", "", "write cpu profile to file")
memProfile := flag.String("memprofile", "", "write mem profile to file")
flag.Parse()
if *cpuProfile != "" {
f, err := os.Create(*cpuProfile)
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
fun = append(fun, pprof.StopCPUProfile)
benchmarking = true
}
if *memProfile != "" {
heapProfileFile, err := os.Create(*memProfile)
if err != nil {
panic(err)
}
fun = append(fun, func() {
pprof.WriteHeapProfile(heapProfileFile)
heapProfileFile.Close()
})
benchmarking = true
}
return fun
}