git://git.iain.cx/iain
/
pstop.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
84f9a5c
)
Add support for profiling
author
Simon J Mudd
<sjmudd@pobox.com>
Fri, 21 Nov 2014 21:37:27 +0000
(22:37 +0100)
committer
Simon J Mudd
<sjmudd@pobox.com>
Fri, 21 Nov 2014 21:37:27 +0000
(22:37 +0100)
main.go
patch
|
blob
|
history
diff --git
a/main.go
b/main.go
index
5a7e87b
..
708a77a
100644
(file)
--- a/
main.go
+++ b/
main.go
@@
-9,6
+9,7
@@
import (
"log"
"os"
"os/signal"
"log"
"os"
"os/signal"
+ "runtime/pprof"
"syscall"
"time"
"syscall"
"time"
@@
-26,6
+27,11
@@
const (
db = "performance_schema"
)
db = "performance_schema"
)
+var flag_version = flag.Bool("version", false, "Show the version of "+lib.MyName())
+var flag_debug = flag.Bool("debug", false, "Enabling debug logging")
+var flag_help = flag.Bool("help", false, "Provide some help for "+lib.MyName())
+var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
+
func get_db_handle() *sql.DB {
var err error
var dbh *sql.DB
func get_db_handle() *sql.DB {
var err error
var dbh *sql.DB
@@
-67,12
+73,18
@@
func usage() {
}
func main() {
}
func main() {
- var flag_version = flag.Bool("version", false, "Show the version of "+lib.MyName())
- var flag_debug = flag.Bool("debug", false, "Enabling debug logging")
- var flag_help = flag.Bool("help", false, "Provide some help for "+lib.MyName())
flag.Parse()
// clean me up
flag.Parse()
// clean me up
+ if *cpuprofile != "" {
+ f, err := os.Create(*cpuprofile)
+ if err != nil {
+ log.Fatal(err)
+ }
+ pprof.StartCPUProfile(f)
+ defer pprof.StopCPUProfile()
+ }
+
if *flag_debug {
lib.Logger.EnableLogging(true)
}
if *flag_debug {
lib.Logger.EnableLogging(true)
}