Skip to content

Commit a9a874d

Browse files
committed
test: stabilize heap stats warmup
Retry JIT warmup before asserting executable heap stats so V8 tiering and GC timing do not leave the metric at zero.
1 parent 215889b commit a9a874d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

test/mini_racer_test.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -890,12 +890,16 @@ def test_estimated_size
890890
context.eval(<<~JS)
891891
let a='testing';
892892
let f=function(foo) { foo + 42 };
893-
894-
// call `f` a lot to have things JIT'd so that total_heap_size_executable becomes > 0
895-
for (let i = 0; i < 1000000; i++) { f(10); }
896893
JS
897894

898-
stats = context.heap_stats
895+
# whether JIT'd code is on the heap when we measure depends on V8 tiering
896+
# and GC timing, so warm up until total_heap_size_executable becomes > 0
897+
stats = nil
898+
5.times do
899+
context.eval("for (let i = 0; i < 1000000; i++) { f(10); }")
900+
stats = context.heap_stats
901+
break if stats[:total_heap_size_executable] > 0
902+
end
899903
# eg: {:total_physical_size=>1280640, :total_heap_size_executable=>4194304, :total_heap_size=>3100672, :used_heap_size=>1205376, :heap_size_limit=>1501560832}
900904
assert_equal(
901905
%i[

0 commit comments

Comments
 (0)