test v8 heap stats and aggregate all
This commit is contained in:
parent
1096dcd602
commit
e7c170bb00
|
@ -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\"]"
|
||||
|
|
|
@ -40,6 +40,18 @@ describe StatsSocket do
|
|||
parsed = JSON.parse(line)
|
||||
|
||||
expect(parsed.keys.sort).to eq(GC.stat.keys.map(&:to_s).sort)
|
||||
|
||||
# make sure we have libv8 going
|
||||
PrettyText.cook("x")
|
||||
|
||||
socket = UNIXSocket.new(socket_path)
|
||||
socket.send "v8_stat\n", 0
|
||||
line = socket.readline
|
||||
socket.close
|
||||
|
||||
parsed = JSON.parse(line)
|
||||
|
||||
expect(parsed['total_physical_size']).to be>(0)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue