| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2010 the V8 project authors. All rights reserved. | 3 # Copyright 2010 the V8 project authors. All rights reserved. |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 script = generate_script_and_datafile(plot, trace, '~datafile', outfilename) | 209 script = generate_script_and_datafile(plot, trace, '~datafile', outfilename) |
| 210 print 'Plotting %s...' % outfilename | 210 print 'Plotting %s...' % outfilename |
| 211 gnuplot(script) | 211 gnuplot(script) |
| 212 | 212 |
| 213 return charts | 213 return charts |
| 214 | 214 |
| 215 def reclaimed_bytes(row): | 215 def reclaimed_bytes(row): |
| 216 return row['total_size_before'] - row['total_size_after'] | 216 return row['total_size_before'] - row['total_size_after'] |
| 217 | 217 |
| 218 def other_scope(r): | 218 def other_scope(r): |
| 219 return r['pause'] - r['mark'] - r['sweep'] - r['compact'] | 219 if r['gc'] == 's': |
| 220 # there is no 'other' scope for scavenging collections. |
| 221 return 0 |
| 222 return r['pause'] - r['mark'] - r['sweep'] - r['compact'] - r['external'] |
| 223 |
| 224 def scavenge_scope(r): |
| 225 if r['gc'] == 's': |
| 226 return r['pause'] - r['external'] |
| 227 return 0 |
| 220 | 228 |
| 221 plots = [ | 229 plots = [ |
| 222 [ | 230 [ |
| 223 Set('style fill solid 0.5 noborder'), | 231 Set('style fill solid 0.5 noborder'), |
| 224 Set('style histogram rowstacked'), | 232 Set('style histogram rowstacked'), |
| 225 Set('style data histograms'), | 233 Set('style data histograms'), |
| 226 Plot(Item('Marking', 'mark', lc = 'purple'), | 234 Plot(Item('Scavenge', scavenge_scope, lc = 'green'), |
| 235 Item('Marking', 'mark', lc = 'purple'), |
| 227 Item('Sweep', 'sweep', lc = 'blue'), | 236 Item('Sweep', 'sweep', lc = 'blue'), |
| 228 Item('Compaction', 'compact', lc = 'red'), | 237 Item('Compaction', 'compact', lc = 'red'), |
| 238 Item('External', 'external', lc = '#489D43'), |
| 229 Item('Other', other_scope, lc = 'grey')) | 239 Item('Other', other_scope, lc = 'grey')) |
| 230 ], | 240 ], |
| 231 [ | 241 [ |
| 232 Set('style histogram rowstacked'), | 242 Set('style histogram rowstacked'), |
| 233 Set('style data histograms'), | 243 Set('style data histograms'), |
| 234 Plot(Item('Heap Size (before GC)', 'total_size_before', x1y2, | 244 Plot(Item('Heap Size (before GC)', 'total_size_before', x1y2, |
| 235 fs = 'solid 0.4 noborder', | 245 fs = 'solid 0.4 noborder', |
| 236 lc = 'green'), | 246 lc = 'green'), |
| 237 Item('Total holes (after GC)', 'holes_size_before', x1y2, | 247 Item('Total holes (after GC)', 'holes_size_before', x1y2, |
| 238 fs = 'solid 0.4 noborder', | 248 fs = 'solid 0.4 noborder', |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 out.write('<table>') | 317 out.write('<table>') |
| 308 out.write('<tr><td>Phase</td><td>Count</td><td>Time (ms)</td>') | 318 out.write('<tr><td>Phase</td><td>Count</td><td>Time (ms)</td>') |
| 309 out.write('<td>Max</td><td>Avg</td></tr>') | 319 out.write('<td>Max</td><td>Avg</td></tr>') |
| 310 stats(out, 'Total in GC', trace, 'pause') | 320 stats(out, 'Total in GC', trace, 'pause') |
| 311 stats(out, 'Scavenge', scavenges, 'pause') | 321 stats(out, 'Scavenge', scavenges, 'pause') |
| 312 stats(out, 'MarkSweep', marksweeps, 'pause') | 322 stats(out, 'MarkSweep', marksweeps, 'pause') |
| 313 stats(out, 'MarkCompact', markcompacts, 'pause') | 323 stats(out, 'MarkCompact', markcompacts, 'pause') |
| 314 stats(out, 'Mark', filter(lambda r: r['mark'] != 0, trace), 'mark') | 324 stats(out, 'Mark', filter(lambda r: r['mark'] != 0, trace), 'mark') |
| 315 stats(out, 'Sweep', filter(lambda r: r['sweep'] != 0, trace), 'sweep') | 325 stats(out, 'Sweep', filter(lambda r: r['sweep'] != 0, trace), 'sweep') |
| 316 stats(out, 'Compact', filter(lambda r: r['compact'] != 0, trace), 'compact') | 326 stats(out, 'Compact', filter(lambda r: r['compact'] != 0, trace), 'compact') |
| 327 stats(out, |
| 328 'External', |
| 329 filter(lambda r: r['external'] != 0, trace), |
| 330 'external') |
| 317 out.write('</table>') | 331 out.write('</table>') |
| 318 for chart in charts: | 332 for chart in charts: |
| 319 out.write('<img src="%s">' % chart) | 333 out.write('<img src="%s">' % chart) |
| 320 out.write('</body></html>') | 334 out.write('</body></html>') |
| 321 | 335 |
| 322 print "%s generated." % (filename + '.html') | 336 print "%s generated." % (filename + '.html') |
| 323 | 337 |
| 324 if len(sys.argv) != 2: | 338 if len(sys.argv) != 2: |
| 325 print "Usage: %s <GC-trace-filename>" % sys.argv[0] | 339 print "Usage: %s <GC-trace-filename>" % sys.argv[0] |
| 326 sys.exit(1) | 340 sys.exit(1) |
| 327 | 341 |
| 328 process_trace(sys.argv[1]) | 342 process_trace(sys.argv[1]) |
| OLD | NEW |