Skip to content

Commit

Permalink
added width, height and output filename options
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0f0f0f committed Jun 25, 2020
1 parent f9bfe85 commit 6441de2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cmd/memplot.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ func main() {
PlotVsz: false,
}

pidPtr := flag.Int("pid", -1, "pid of the process to analyze")

// Default sample duration time
defaultSd, err := time.ParseDuration("5ms")
check(err)
Expand All @@ -33,15 +31,28 @@ func main() {
defaultDur, err := time.ParseDuration("10s")
check(err)

defaultFilename := "output-plot.png"
pidPtr := flag.Int("pid", -1, "pid of the process to analyze")
filenamePtr := flag.String("o", defaultFilename, "output image file name")
sdPtr := flag.Duration("sd", defaultSd, "sample size in time")
durPtr := flag.Duration("dur", defaultDur, "total profiling time")

// To plot or not VSZ
flag.BoolVar(&opts.PlotVsz, "vsz", false, "plot virtual size")

widthStr := flag.String("w", "16cm", "plot image width (can be cm or in)")
heightStr := flag.String("h", "12cm", "plot image height (can be cm or in)")

flag.Parse()

// Checks for valid flags
if *pidPtr <= 0 {
panic(errors.New("Invalid PID. Please specify a PID using -pid flag"))
}
widthImage, err := vg.ParseLength(*widthStr)
check(err)
heightImage, err := vg.ParseLength(*heightStr)
check(err)

// Create and sample
fmt.Fprintln(os.Stderr, "Analyzing PID", *pidPtr, "...")
Expand All @@ -53,6 +64,6 @@ func main() {
check(err)

fmt.Fprintln(os.Stderr, "Saving plot..")
memplot.SavePlot(plot, 8*vg.Inch, 8*vg.Inch, "plot.png")
memplot.SavePlot(plot, widthImage, heightImage, *filenamePtr)

}
1 change: 1 addition & 0 deletions memplot.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (m *MemoryCollection) Plot(opt PlotOptions) (*plot.Plot, error) {
p.Legend.Add("RSS", rssLine)
}

// TODO add another Y axis for vsz
if opt.PlotVsz {
// RSS line plotter and style
vszData := m.GatherVSZXYs()
Expand Down

0 comments on commit 6441de2

Please sign in to comment.