Module: Ritsudo::Result::Uncompletable

Includes:
Helper
Included in:
Documents, Scripts, Xhrs
Defined in:
lib/ritsudo/result/uncompletable.rb

Instance Method Summary collapse

Methods included from Helper

mean, remove_outliters, standard_deviation, variance

Instance Method Details

#add(request) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ritsudo/result/uncompletable.rb', line 6

def add(request)
  @requests ||= []
  @uncompleted ||= Hash.new
  @requests << request.url
  @uncompleted[request.url] ||= 0
  if request.time
    @completed[request.url] << request.time
  else
    @uncompleted[request.url] += 1
  end
end

#nameObject

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/ritsudo/result/uncompletable.rb', line 18

def name
  raise NotImplementedError
end

#report(outliters_stdev_multiple: nil) ⇒ Object



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
49
50
51
52
53
54
55
56
57
58
# File 'lib/ritsudo/result/uncompletable.rb', line 22

def report(outliters_stdev_multiple: nil)
  puts "[#{name}]"
  table_data = []
  (@requests || []).uniq.each do |url|
    if @completed[url] && !@completed[url].empty?
      all_request_times = @completed[url]
      use_remove_outliters = outliters_stdev_multiple && all_request_times.size > 1

      if use_remove_outliters
        request_times = Ritsudo::Result::Helper.remove_outliters(all_request_times, outliters_stdev_multiple)
      else
        request_times = all_request_times
      end

      avg   = (request_times.sum(0.0) / request_times.length)&.round(2)
      max   = request_times.max&.round(2)
      min   = request_times.min&.round(2)
      count = request_times.size
    else
      avg = max = min = count = "-"
    end

    result = {
      url:         url[0..100],
      avg:         avg,
      max:         max,
      min:         min,
      count:       count,
      uncompleted: @uncompleted[url],
      outliters:   all_request_times.size - request_times.size
    }


    table_data << result
  end
  Formatador.display_table(table_data, [:url, :avg, :max, :min, :count, :uncompleted, :outliters])
end