test v8 heap stats and aggregate all

This commit is contained in:
Sam
2017-07-20 13:23:48 -04:00
parent 1096dcd602
commit e7c170bb00
2 changed files with 18 additions and 0 deletions

View File

@@ -14,6 +14,12 @@ class StatsSocket < SocketServer
when "gc_stat"
GC.stat.to_json
when "v8_stat"
stats = {}
ObjectSpace.each_object(MiniRacer::Context) do |context|
context.heap_stats.each do |k,v|
stats[k] = (stats[k] || 0) + v
end
end
PrettyText.v8.heap_stats.to_json
else
"[\"UNKNOWN COMMAND\"]"