@@ -23,8 +23,6 @@ func main() {
23
23
PlotVsz : false ,
24
24
}
25
25
26
- pidPtr := flag .Int ("pid" , - 1 , "pid of the process to analyze" )
27
-
28
26
// Default sample duration time
29
27
defaultSd , err := time .ParseDuration ("5ms" )
30
28
check (err )
@@ -33,15 +31,28 @@ func main() {
33
31
defaultDur , err := time .ParseDuration ("10s" )
34
32
check (err )
35
33
34
+ defaultFilename := "output-plot.png"
35
+ pidPtr := flag .Int ("pid" , - 1 , "pid of the process to analyze" )
36
+ filenamePtr := flag .String ("o" , defaultFilename , "output image file name" )
36
37
sdPtr := flag .Duration ("sd" , defaultSd , "sample size in time" )
37
38
durPtr := flag .Duration ("dur" , defaultDur , "total profiling time" )
38
39
40
+ // To plot or not VSZ
39
41
flag .BoolVar (& opts .PlotVsz , "vsz" , false , "plot virtual size" )
40
42
43
+ widthStr := flag .String ("w" , "16cm" , "plot image width (can be cm or in)" )
44
+ heightStr := flag .String ("h" , "12cm" , "plot image height (can be cm or in)" )
45
+
41
46
flag .Parse ()
47
+
48
+ // Checks for valid flags
42
49
if * pidPtr <= 0 {
43
50
panic (errors .New ("Invalid PID. Please specify a PID using -pid flag" ))
44
51
}
52
+ widthImage , err := vg .ParseLength (* widthStr )
53
+ check (err )
54
+ heightImage , err := vg .ParseLength (* heightStr )
55
+ check (err )
45
56
46
57
// Create and sample
47
58
fmt .Fprintln (os .Stderr , "Analyzing PID" , * pidPtr , "..." )
@@ -53,6 +64,6 @@ func main() {
53
64
check (err )
54
65
55
66
fmt .Fprintln (os .Stderr , "Saving plot.." )
56
- memplot .SavePlot (plot , 8 * vg . Inch , 8 * vg . Inch , "plot.png" )
67
+ memplot .SavePlot (plot , widthImage , heightImage , * filenamePtr )
57
68
58
69
}
0 commit comments