15
15
def inst_unit_scaling (peak ):
16
16
"""
17
17
Given the peak instruction value to plot, get a scaling factor which will
18
- divide the data point and the resulting unit name. Those informations is
18
+ divide the data point and the resulting unit name. These information are
19
19
used to scale the data and set the axis label in the print_gnuplot_script
20
20
function.
21
21
"""
22
-
23
22
unit_table = [
24
23
(2 ** 0 , "i" ),
25
24
(2 ** 10 , "ki" ),
@@ -38,10 +37,9 @@ def inst_unit_scaling(peak):
38
37
def time_unit_scaling (peak ):
39
38
"""
40
39
Given the peak time value to plot, get a scaling factor which will divide
41
- the data point and the resulting unit name. Those informations is used to
40
+ the data point and the resulting unit name. These information are used to
42
41
scale the data and set the axis label in the print_gnuplot_script function.
43
42
"""
44
-
45
43
if peak // 1000 < 1 :
46
44
return (1 , "milliseconds (ms)" )
47
45
elif 1 <= peak // 1000 < 60 :
@@ -53,10 +51,9 @@ def time_unit_scaling(peak):
53
51
def memory_unit_scaling (peak ):
54
52
"""
55
53
Given the peak memory value to plot, get a scaling factor which will divide
56
- the data point and the resulting unit name. Those informations is used to
54
+ the data point and the resulting unit name. These information are used to
57
55
scale the data and set the axis label in the print_gnuplot_script function.
58
56
"""
59
-
60
57
unit_table = [
61
58
(2 ** 0 , "bytes (B)" ),
62
59
(2 ** 10 , "kibibytes (KiB)" ),
@@ -76,7 +73,6 @@ def print_as_json(mdata, indent):
76
73
"""
77
74
Print mdata as json. If indent is true, the outputed json is indented.
78
75
"""
79
-
80
76
if indent :
81
77
print (json .dumps (mdata , indent = 1 ))
82
78
else :
@@ -87,7 +83,6 @@ def print_gnuplot_dtable(mdata):
87
83
"""
88
84
Print mdata as a data table ready for gnuplot consumption.
89
85
"""
90
-
91
86
print ("# ms_processor.py - (C) Mathieu Turcotte, 2011" )
92
87
print ("# valgrind --tool=massif" , mdata ["desc" ], mdata ["cmd" ])
93
88
print ("# id" , "time" , "heap" , "extra" , "total" , "stack" , sep = "\t " )
@@ -124,16 +119,14 @@ def print_gnuplot_script(mdata, filename, format="png", xsize=1024, ysize=768):
124
119
Print mdata as a gnuplot batch script which, when executed, will produce a
125
120
plot of the massif.out data.
126
121
"""
127
-
128
- # Retrieve the time peak and determine the y axis
129
- # scale and label.
122
+ # Retrieve the time peak and determine the y axis scale and label.
130
123
peak_snapshot_id = mdata ["peak_snapshot" ]
131
124
peak_snapshot = mdata ["snapshots" ][peak_snapshot_id ]
132
125
memory_peak = peak_snapshot ["mem_heap" ] + peak_snapshot ["mem_heap_extra" ]
133
126
(yscale , ylabel ) = memory_unit_scaling (memory_peak )
134
127
135
- # Retrieve the time peak and the time unit in order
136
- # to calculate the x axis scale and label.
128
+ # Retrieve the time peak and the time unit in order to compute the x
129
+ # axis scale and label.
137
130
time_peak = mdata ["snapshots" ][- 1 ]["time" ]
138
131
time_unit = mdata ["time_unit" ]
139
132
if time_unit == "B" :
@@ -250,10 +243,10 @@ def parse_args():
250
243
251
244
def main ():
252
245
(options , args ) = parse_args ()
246
+
253
247
for path in args [0 :]:
254
248
try :
255
249
mdata = msparser .parse_file (path )
256
-
257
250
if options .output == "json" :
258
251
print_as_json (mdata , options .indent )
259
252
elif options .output == "gnuplot" :
@@ -262,7 +255,6 @@ def main():
262
255
options .ysize )
263
256
elif options .output == "table" :
264
257
print_gnuplot_dtable (mdata )
265
-
266
258
except ParseError as perr :
267
259
print (perr , file = sys .stderr )
268
260
0 commit comments