Move profiler to main
parent
0dc2425a6c
commit
1d0b139a3a
|
@ -6,6 +6,9 @@ import (
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"runtime/pprof"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -203,6 +206,29 @@ func BenchThread(cephconn *Cephconnection, osddevice Device, buffs [][]byte, par
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
params := Route()
|
params := Route()
|
||||||
|
if params.cpuprofile != "" {
|
||||||
|
f, err := os.Create(params.cpuprofile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("could not create CPU profile: ", err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
if err := pprof.StartCPUProfile(f); err != nil {
|
||||||
|
log.Fatal("could not start CPU profile: ", err)
|
||||||
|
}
|
||||||
|
defer pprof.StopCPUProfile()
|
||||||
|
}
|
||||||
|
|
||||||
|
if params.memprofile != "" {
|
||||||
|
f, err := os.Create(params.memprofile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("could not create memory profile: ", err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
runtime.GC() // get up-to-date statistics
|
||||||
|
if err := pprof.WriteHeapProfile(f); err != nil {
|
||||||
|
log.Fatal("could not write memory profile: ", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
cephconn := connectioninit(params)
|
cephconn := connectioninit(params)
|
||||||
defer cephconn.conn.Shutdown()
|
defer cephconn.conn.Shutdown()
|
||||||
|
|
||||||
|
|
27
flags.go
27
flags.go
|
@ -4,9 +4,6 @@ import (
|
||||||
"code.cloudfoundry.org/bytefmt"
|
"code.cloudfoundry.org/bytefmt"
|
||||||
"github.com/juju/gnuflag"
|
"github.com/juju/gnuflag"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"runtime/pprof"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,30 +55,6 @@ func Route() Params {
|
||||||
"Name of memprofile")
|
"Name of memprofile")
|
||||||
gnuflag.Parse(true)
|
gnuflag.Parse(true)
|
||||||
|
|
||||||
if params.cpuprofile != "" {
|
|
||||||
f, err := os.Create(params.cpuprofile)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("could not create CPU profile: ", err)
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
if err := pprof.StartCPUProfile(f); err != nil {
|
|
||||||
log.Fatal("could not start CPU profile: ", err)
|
|
||||||
}
|
|
||||||
defer pprof.StopCPUProfile()
|
|
||||||
}
|
|
||||||
|
|
||||||
if params.memprofile != "" {
|
|
||||||
f, err := os.Create(params.memprofile)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("could not create memory profile: ", err)
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
runtime.GC() // get up-to-date statistics
|
|
||||||
if err := pprof.WriteHeapProfile(f); err != nil {
|
|
||||||
log.Fatal("could not write memory profile: ", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
blocksize, err := bytefmt.ToBytes(params.bs)
|
blocksize, err := bytefmt.ToBytes(params.bs)
|
||||||
params.blocksize = blocksize
|
params.blocksize = blocksize
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue