diff options
author | Eric Wong <e@80x24.org> | 2018-07-15 00:48:57 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-07-16 19:34:32 +0000 |
commit | 686f336d457106d27d04b01baf121fd2f12fd671 (patch) | |
tree | 13b0d4f05e4f9280b6cc0b9b7a97624f97f78434 /test/test_mwrap.rb | |
parent | 1a589f1813ec1b46f6701ab40b2fe2605ae426c5 (diff) | |
download | mwrap-686f336d457106d27d04b01baf121fd2f12fd671.tar.gz |
This can be useful in apps to analyze what's live and what's not.
Diffstat (limited to 'test/test_mwrap.rb')
-rw-r--r-- | test/test_mwrap.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_mwrap.rb b/test/test_mwrap.rb index d0af0f7..686d87d 100644 --- a/test/test_mwrap.rb +++ b/test/test_mwrap.rb @@ -163,6 +163,34 @@ class TestMwrap < Test::Unit::TestCase end end + def test_aref_each + cmd = @@cmd + %w( + -e count=GC.count + -e GC.disable + -e keep=("0"*10000) + -e loc=Mwrap["-e:3"] + -e loc.each{|size,gen|p([size,gen,count])} + ) + buf = IO.popen(@@env, cmd, &:read) + assert_predicate $?, :success? + assert_match(/\A\[\s*\d+,\s*\d+,\s*\d+\]\s*\z/s, buf) + size, gen, count = eval(buf) + assert_operator size, :>=, 10000 + assert_operator gen, :>=, count + + cmd = @@cmd + %w( + -e count=GC.count + -e locs="" + -e Mwrap.each(1){|loc,tot,calls|locs<<loc} + -e m=locs.match(/(\[0x[a-f0-9]+\])/i) + -e p(loc=Mwrap["bobloblaw\t#{m[1]}"]) + -e loc.each{|size,gen|p([size,gen,count])} + ) + buf = IO.popen(@@env, cmd, &:read) + assert_predicate $?, :success? + assert_match(/\bMwrap::SourceLocation\b/, buf) + end + def test_benchmark cmd = @@cmd + %w(-rbenchmark -e puts(Benchmark.measure{1000000.times{Time.now}})) |