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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 marksweeps = filter(lambda r: r['gc'] == 'ms', trace) | 281 marksweeps = filter(lambda r: r['gc'] == 'ms', trace) |
282 markcompacts = filter(lambda r: r['gc'] == 'mc', trace) | 282 markcompacts = filter(lambda r: r['gc'] == 'mc', trace) |
283 scavenges = filter(lambda r: r['gc'] == 's', trace) | 283 scavenges = filter(lambda r: r['gc'] == 's', trace) |
284 | 284 |
285 charts = plot_all(plots, trace, filename) | 285 charts = plot_all(plots, trace, filename) |
286 | 286 |
287 def stats(out, prefix, trace, field): | 287 def stats(out, prefix, trace, field): |
288 n = len(trace) | 288 n = len(trace) |
289 total = calc_total(trace, field) | 289 total = calc_total(trace, field) |
290 max = calc_max(trace, field) | 290 max = calc_max(trace, field) |
291 avg = total / n | 291 if n > 0: |
| 292 avg = total / n |
| 293 else: |
| 294 avg = 0 |
292 if n > 1: | 295 if n > 1: |
293 dev = math.sqrt(freduce(lambda t,r: (r - avg) ** 2, field, trace, 0) / | 296 dev = math.sqrt(freduce(lambda t,r: (r - avg) ** 2, field, trace, 0) / |
294 (n - 1)) | 297 (n - 1)) |
295 else: | 298 else: |
296 dev = 0 | 299 dev = 0 |
297 | 300 |
298 out.write('<tr><td>%s</td><td>%d</td><td>%d</td>' | 301 out.write('<tr><td>%s</td><td>%d</td><td>%d</td>' |
299 '<td>%d</td><td>%d [dev %f]</td></tr>' % | 302 '<td>%d</td><td>%d [dev %f]</td></tr>' % |
300 (prefix, n, total, max, avg, dev)) | 303 (prefix, n, total, max, avg, dev)) |
301 | 304 |
(...skipping 15 matching lines...) Expand all Loading... |
317 out.write('<img src="%s">' % chart) | 320 out.write('<img src="%s">' % chart) |
318 out.write('</body></html>') | 321 out.write('</body></html>') |
319 | 322 |
320 print "%s generated." % (filename + '.html') | 323 print "%s generated." % (filename + '.html') |
321 | 324 |
322 if len(sys.argv) != 2: | 325 if len(sys.argv) != 2: |
323 print "Usage: %s <GC-trace-filename>" % sys.argv[0] | 326 print "Usage: %s <GC-trace-filename>" % sys.argv[0] |
324 sys.exit(1) | 327 sys.exit(1) |
325 | 328 |
326 process_trace(sys.argv[1]) | 329 process_trace(sys.argv[1]) |
OLD | NEW |