Name | Written in | Usable in | API and notes |
---|---|---|---|
CRuby parse.y | C | usable from C (maybe) | no official API, not easily reusable/not standalone |
Ripper |
C | Ruby | awkward API |
RubyVM::AbstractSyntaxTree |
C | Ruby | awkward API, not portable API |
whitequark/parser | Ruby | Ruby | Nice API |
ruby_parser | Ruby | Ruby | up-to-date? |
lib-ruby-parser | Rust | C/C++/Ruby (see bindings | |
natalie_parser | C++ | C++/C | |
JRuby's parser | Java | Java | depends on quite a few JRuby internals |
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
def Process.rss | |
Integer(`ps -o rss= -p #{Process.pid}`) * 1024 | |
end | |
def mb(bytes) | |
return '?' if bytes == nil or bytes < 0 | |
mb = bytes / 1024.0 / 1024.0 | |
"#{mb.to_i} MB" | |
end |
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
command = ARGV | |
start = Process.clock_gettime Process::CLOCK_MONOTONIC, :millisecond | |
IO.popen(command, err: [:child, :out]) do |io| | |
while line = io.gets | |
now = Process.clock_gettime Process::CLOCK_MONOTONIC, :millisecond | |
puts "[#{"%5d" % (now - start)}] #{line}" | |
end | |
end |
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
require 'tmpdir' | |
require 'rbconfig' | |
def inline_c_extension(c_code) | |
Dir.mktmpdir('inline_c_extension') do |dir| | |
File.write("#{dir}/cext.c", c_code) | |
File.write("#{dir}/extconf.rb", <<~RUBY) | |
require 'mkmf' | |
create_makefile('cext') | |
RUBY |
Ruby Implementation | Speedup relative to 2.7.2 |
---|---|
Ruby 2.7.2 | 1.00x |
Ruby 2.7.2 --jit | 1.16x |
Ruby 3 dev | 0.81x |
Ruby 3 dev --jit | 1.08x |
TruffleRuby CE 20.2 --jvm | 19.73x |
TruffleRuby EE 20.2 --jvm | 31.54x |
The median i/s result out of 3 is used to compute speedups.
Ruby | Core methods written in Ruby | Total number of core methods | % written in Ruby |
---|---|---|---|
CRuby 2.3 | 3 | 1637 | 0.2% |
CRuby 2.4 | 3 | 1636 | 0.2% |
CRuby 2.5 | 6 | 1680 | 0.4% |
CRuby 2.6 | 5 | 1767 | 0.3% |
CRuby 2.7 | 38 | 1802 | 2.1% |
CRuby 3.0 | 89 | 1830 | 4.9% |
CRuby 3.1 | 112 | 1884 | 5.9% |
CRuby 3.2 | 128 | 1924 | 6.7% |
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
I added `x.compare!` in bin/benchmark | |
$ cd ext | |
$ rake | |
$ cd .. | |
$ gem install ffi-compiler benchmark-ips | |
$ ruby -Ilib bin/benchmark | |
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux] |
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
#!/usr/bin/env ruby | |
private def benchmark(name = nil, &block) | |
raise "needs a block" unless block | |
binding = block.binding | |
file, line = block.source_location | |
start_line = line - 1 | |
lines = File.readlines(file) | |
indent = lines.fetch(start_line)[/^(\s+)/, 1] |
-
Add Graal JIT Compilation to Your JVM Language in 5 Steps, A Tutorial http://stefan-marr.de/2015/11/add-graal-jit-compilation-to-your-jvm-language-in-5-easy-steps-step-1/
-
The SimpleLanguage, an example of using Truffle with great JavaDocs. It is the officle getting-started project: https://github.com/graalvm/simplelanguage
-
Truffle Tutorial, Christan Wimmer, PLDI 2016, 3h recording https://youtu.be/FJY96_6Y3a4 Slides
NewerOlder