Skip to content

Commit fad7781

Browse files
Add total heap memory to heap summary stats
1 parent 3f978f6 commit fad7781

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

harness-gc/harness.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ def run_benchmark(_num_itrs_hint, **, &block)
136136

137137
# Print heap utilisation table
138138
if heap_snapshot
139+
page_size = defined?(GC::INTERNAL_CONSTANTS) ? GC::INTERNAL_CONSTANTS[:HEAP_PAGE_SIZE] : nil
140+
139141
puts "\nHeap utilisation (after full GC):"
140-
header = "heap slot_size eden_slots live_slots free_slots eden_pages live_pct"
142+
header = "heap slot_size eden_slots live_slots free_slots eden_pages live_pct mem_KiB"
141143
puts header
142144

143145
heap_snapshot.each do |idx, stats|
@@ -147,9 +149,10 @@ def run_benchmark(_num_itrs_hint, **, &block)
147149
free_slots = stats[:heap_free_slots] || 0
148150
eden_pages = stats[:heap_eden_pages] || 0
149151
live_pct = eden_slots > 0 ? (live_slots * 100.0 / eden_slots) : 0.0
152+
mem_kib = page_size ? (eden_pages * page_size / 1024.0) : 0.0
150153

151-
puts "%4d %9d %10d %10d %10d %11d %7.1f%%" % [
152-
idx, slot_size, eden_slots, live_slots, free_slots, eden_pages, live_pct
154+
puts "%4d %9d %10d %10d %10d %11d %7.1f%% %7.1f" % [
155+
idx, slot_size, eden_slots, live_slots, free_slots, eden_pages, live_pct, mem_kib
153156
]
154157
end
155158
end

0 commit comments

Comments
 (0)