| 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 hidden or 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] |
This file contains hidden or 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 |
This file contains hidden or 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 "json" | |
| struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] } | |
| source = JSON.dump(struct) | |
| tokens = [] | |
| index = 0 | |
| until source.empty? | |
| tokens << |
This file contains hidden or 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 | |
| class Stats | |
| def initialize(data) | |
| @data = data | |
| @sorted = data.sort | |
| end | |
| def size | |
| @data.size |
OlderNewer