Sha256: 40ed75e82819122183bf80735f48d6a0dc4adb991e0b9592820e5f2adb644eb4
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
require 'test_helper' require 'mirrors/visitors/disasm_visitor' module Mirrors class ISeqVisitorTest < MiniTest::Test class CountingVisitor < Mirrors::ISeqVisitor attr_reader :count def initialize @count = 0 end def visit(_bytecode) @count += 1 end end def test_all_methods class_count = 0 method_count = 0 bytecode_count = 0 smallest = 1024 smallest_method = nil largest = 0 largest_method = nil Mirrors.classes.each do |clazz| clazz.methods.each do |meth| visitor = CountingVisitor.new visitor.call(meth) bytecode_count += visitor.count if visitor.count > largest largest = visitor.count largest_method = meth end if visitor.count < smallest && visitor.count > 0 smallest = visitor.count smallest_method = meth end bytecode_count += visitor.count method_count += 1 end class_count += 1 end assert(class_count >= 788) assert(method_count >= 4782) assert(bytecode_count >= 47308) puts "Walked #{class_count} classes with #{method_count} methods and #{bytecode_count} bytecodes." puts "Largest method #{largest_method.defining_class.name}.#{largest_method.name}, #{largest} bytecodes." puts "Smallest method #{smallest_method.defining_class.name}.#{smallest_method.name}, #{smallest} bytecodes." puts "Average method #{bytecode_count / method_count} bytecodes." end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mirrors-0.0.3 | test/mirrors/iseq_visitor_test.rb |
mirrors-0.0.2 | test/mirrors/iseq_visitor_test.rb |
mirrors-0.0.1 | test/mirrors/iseq_visitor_test.rb |