Created
February 2, 2022 00:33
-
-
Save chrisseaton/62f75ca5e171ccdf39f5c1b509b254c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`curl -OL https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.3.3.0/jruby-dist-9.3.3.0-bin.tar.gz` unless File.exist?('jruby-dist-9.3.3.0-bin.tar.gz') | |
`tar -zxf jruby-dist-9.3.3.0-bin.tar.gz` unless Dir.exist?('jruby-9.3.3.0') | |
`curl -OL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz` unless File.exist?('graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz') | |
`tar -zxf graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz` unless Dir.exist?('graalvm-ce-java17-22.0.0.2') | |
`gem install seafoam` | |
IO.popen({'JAVA_HOME' => 'graalvm-ce-java17-22.0.0.2/Contents/Home'}, ['jruby-9.3.3.0/bin/jruby', '-J-XX:CompileOnly=DashE::RUBY$method$foo$1', '-J-XX:+PrintCompilation', '-J-Dgraal.Dump=', '-e', 'def foo(a, b); a + b; end; loop { foo(rand(100), rand(100)) }']) do |pipe| | |
puts 'Running...' | |
pipe.each_line do |line| | |
if line =~ /\s+\d+\s+\d+\s+4\s+DashE::RUBY\$method\$foo\$1 \(\d+ bytes\)/ | |
sleep 3 | |
puts 'Killing...' | |
Process.kill 9, pipe.pid | |
sleep 3 | |
puts 'Joining...' | |
Process.wait pipe.pid | |
end | |
end | |
end | |
graph = Dir.glob('graal_dumps/*/*.bgv').to_a.sort.last | |
# system 'seafoam', "#{graph}:2", 'render' install Graphviz and use this to see what the graph is | |
system 'seafoam', "#{graph}:2", 'describe' | |
# 10 nodes, calls, linear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment