[#109095] [Ruby master Misc#18888] Migrate ruby-lang.org mail services to Google Domains and Google Workspace — "shugo (Shugo Maeda)" <noreply@...>
Issue #18888 has been reported by shugo (Shugo Maeda).
16 messages
2022/06/30
[ruby-core:108968] [Ruby master Feature#18835] Add InstructionSequence#type method
From:
"tenderlovemaking (Aaron Patterson)" <noreply@...>
Date:
2022-06-16 22:30:36 UTC
List:
ruby-core #108968
Issue #18835 has been reported by tenderlovemaking (Aaron Patterson).
----------------------------------------
Feature #18835: Add InstructionSequence#type method
https://bugs.ruby-lang.org/issues/18835
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* Priority: Normal
----------------------------------------
This method returns a symbol representing the type of the instruction
sequence object.
I'm trying to collect some statistics about instruction sequences for an entire system, but I mostly care about methods and blocks. This feature lets me select only methods and blocks to analyze.
I am using a script like this:
```ruby
def walk iseq
case iseq.type
when :METHOD, :BLOCK
count = 0
sends = 0
iseq.to_a.last.each do |insn|
count += 1 if insn.is_a?(Array)
case insn
in [:opt_send_without_block, _]
sends += 1
in [:send, _]
sends += 1
in [:invokeblock]
sends += 1
else
end
end
p [count, sends]
end
iseq.each_child { |n| walk(n) }
end
iseq = RubyVM::InstructionSequence.compile_file(ARGV[0])
walk iseq
```
Then in my shell I can do this:
```
$ find ~/git/rails/activerecord/lib -name '*.rb' -exec ./miniruby test.rb {} \;
```
I'm able to calculate instructions per method as well as number of "sends" per iseq. (Of course this isn't 100% accurate because of metaprogramming etc, but I think it lets us get good estimates)
I made a pull request [here](https://github.com/ruby/ruby/pull/5809) and I've attached a patch as well.
---Files--------------------------------
0001-Add-InstructionSequence-type-method.patch (2.16 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>