@@ -41,7 +41,8 @@ def run_memleak_test(bench, iterations, report):
41
41
print ("{0: 4d}: pymalloc {1: 10d}, rss {2: 10d}, nobjs {3: 10d}, "
42
42
"garbage {4: 4d}, files: {5: 4d}" .format (
43
43
i , malloc , rss , nobjs , garbage , open_files ))
44
-
44
+ if i == starti :
45
+ print ('{:-^86s}' .format (' warmup done ' ))
45
46
malloc_arr [i ] = malloc
46
47
rss_arr [i ] = rss
47
48
if rss > rss_peak :
@@ -55,18 +56,25 @@ def run_memleak_test(bench, iterations, report):
55
56
np .sum (rss_peaks [starti + 1 :] - rss_peaks [starti :- 1 ]) / (endi - starti )))
56
57
57
58
from matplotlib import pyplot as plt
59
+ from matplotlib .ticker import EngFormatter
60
+ bytes_formatter = EngFormatter (unit = 'B' )
58
61
fig , (ax1 , ax2 , ax3 ) = plt .subplots (3 )
62
+ for ax in (ax1 , ax2 , ax3 ):
63
+ ax .axvline (starti , linestyle = '--' , color = 'k' )
59
64
ax1b = ax1 .twinx ()
60
- ax1 .plot (malloc_arr , 'r' )
61
- ax1b .plot (rss_arr , 'b' )
62
- ax1 .set_ylabel ('pymalloc' , color = 'r' )
63
- ax1b .set_ylabel ('rss' , color = 'b' )
65
+ ax1b .yaxis .set_major_formatter (bytes_formatter )
66
+ ax1 .plot (malloc_arr , 'C0' )
67
+ ax1b .plot (rss_arr , 'C1' , label = 'rss' )
68
+ ax1b .plot (rss_peaks , 'C1' , linestyle = '--' , label = 'rss max' )
69
+ ax1 .set_ylabel ('pymalloc' , color = 'C0' )
70
+ ax1b .set_ylabel ('rss' , color = 'C1' )
71
+ ax1b .legend ()
64
72
65
73
ax2b = ax2 .twinx ()
66
- ax2 .plot (nobjs_arr , 'r ' )
67
- ax2b .plot (garbage_arr , 'b ' )
68
- ax2 .set_ylabel ('total objects' , color = 'r ' )
69
- ax2b .set_ylabel ('garbage objects' , color = 'b ' )
74
+ ax2 .plot (nobjs_arr , 'C0 ' )
75
+ ax2b .plot (garbage_arr , 'C1 ' )
76
+ ax2 .set_ylabel ('total objects' , color = 'C0 ' )
77
+ ax2b .set_ylabel ('garbage objects' , color = 'C1 ' )
70
78
71
79
ax3 .plot (open_files_arr )
72
80
ax3 .set_ylabel ('open file handles' )
@@ -107,6 +115,7 @@ def __call__(self):
107
115
ax .pcolor (10 * np .random .rand (50 , 50 ))
108
116
109
117
fig .savefig (BytesIO (), dpi = 75 )
118
+ fig .canvas .flush_events ()
110
119
plt .close (1 )
111
120
112
121
0 commit comments