ruby/benchmark/hash_aref_str_lit.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 строка
622 B
YAML
Исходник Обычный вид История

prelude: |
# frozen_string_literal: true
hash = 10.times.to_h do |i|
[i, i]
end
dyn_sym = "dynamic_symbol".to_sym
binary = RubyVM::InstructionSequence.compile("# frozen_string_literal: true\n'iseq_load'").to_binary
iseq_literal_string = RubyVM::InstructionSequence.load_from_binary(binary).eval
hash[:some_symbol] = 1
hash[dyn_sym] = 2
hash["small"] = 3
hash["frozen_string_literal"] = 4
hash[iseq_literal_string] = 5
benchmark:
symbol: hash[:some_symbol]
dyn_symbol: hash[dyn_sym]
small_lit: hash["small"]
frozen_lit: hash["frozen_string_literal"]
iseq_lit: hash[iseq_literal_string]