MCPcopy Index your code
hub / github.com/nodejs/node / process_trace

Function process_trace

deps/v8/tools/gc-nvp-trace-processor.py:287–364  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

285
286
287def process_trace(filename):
288 trace = gc_nvp_common.parse_gc_trace(filename)
289
290 marksweeps = filter(lambda r: r['gc'] == 'ms', trace)
291 scavenges = filter(lambda r: r['gc'] == 's', trace)
292 globalgcs = filter(lambda r: r['gc'] != 's', trace)
293
294
295 charts = plot_all(plots, trace, filename)
296
297 def stats(out, prefix, trace, field):
298 n = len(trace)
299 total = calc_total(trace, field)
300 max = calc_max(trace, field)
301 if n > 0:
302 avg = total / n
303 else:
304 avg = 0
305 if n > 1:
306 dev = math.sqrt(freduce(lambda t,r: t + (r - avg) ** 2, field, trace, 0) /
307 (n - 1))
308 else:
309 dev = 0
310
311 out.write('<tr><td>%s</td><td>%d</td><td>%d</td>'
312 '<td>%d</td><td>%d [dev %f]</td></tr>' %
313 (prefix, n, total, max, avg, dev))
314
315 def HumanReadable(size):
316 suffixes = ['bytes', 'kB', 'MB', 'GB']
317 power = 1
318 for i in range(len(suffixes)):
319 if size < power*1024:
320 return "%.1f" % (float(size) / power) + " " + suffixes[i]
321 power *= 1024
322
323 def throughput(name, trace):
324 total_live_after = calc_total(trace, 'total_size_after')
325 total_live_before = calc_total(trace, 'total_size_before')
326 total_gc = calc_total(trace, 'pause')
327 if total_gc == 0:
328 return
329 out.write('GC %s Throughput (after): %s / %s ms = %s/ms<br/>' %
330 (name,
331 HumanReadable(total_live_after),
332 total_gc,
333 HumanReadable(total_live_after / total_gc)))
334 out.write('GC %s Throughput (before): %s / %s ms = %s/ms<br/>' %
335 (name,
336 HumanReadable(total_live_before),
337 total_gc,
338 HumanReadable(total_live_before / total_gc)))
339
340
341 with open(filename + '.html', 'w') as out:
342 out.write('<html><body>')
343 out.write('<table>')
344 out.write('<tr><td>Phase</td><td>Count</td><td>Time (ms)</td>')

Callers 1

Calls 7

plot_allFunction · 0.85
throughputFunction · 0.85
statsFunction · 0.70
printFunction · 0.70
filterFunction · 0.50
openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…