Class: RaaP::MethodProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/raap/method_property.rb

Defined Under Namespace

Classes: Stats

Instance Method Summary collapse

Constructor Details

#initialize(receiver_type:, method_name:, method_type:, size_step:, timeout:, allow_private: false) ⇒ MethodProperty



11
12
13
14
15
16
17
18
# File 'lib/raap/method_property.rb', line 11

def initialize(receiver_type:, method_name:, method_type:, size_step:, timeout:, allow_private: false)
  @receiver_type = receiver_type
  @method_name = method_name
  @method_type = method_type
  @size_step = size_step
  @timeout = timeout
  @allow_private = allow_private
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/raap/method_property.rb', line 20

def run
  stats = Stats.new
  begin
    Timeout.timeout(@timeout) do
      catch(:break) do
        @size_step.each do |size|
          call(size: size, stats: stats).tap do |ret|
            case ret
            when Result::Success
              stats.success += 1
            when Result::Failure
              # no count
            when Result::Skip
              stats.skip += 1
            when Result::Exception
              stats.exception += 1
            end

            yield ret
          end
        end
      end
    end
  rescue Timeout::Error => exception
    stats.break = true
    RaaP.logger.info "Timeout: #{exception}"
  end
  stats
end