Class: ProconBypassMan::Procon::PerformanceMeasurement::MeasurementsSummarizer

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb

Defined Under Namespace

Classes: PerformanceMetric

Instance Method Summary collapse

Constructor Details

#initialize(spans:) ⇒ MeasurementsSummarizer

Returns a new instance of MeasurementsSummarizer.



19
20
21
# File 'lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb', line 19

def initialize(spans: )
  @spans = spans
end

Instance Method Details

#summarizePerformanceMetric

NOTE 中央値の表示価値が低いのでコメントアウト

Returns:



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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb', line 25

def summarize

  write_time_max = 0
  read_time_max = 0
  time_taken_max = 0
  external_input_time_max = 0
  interval_from_previous_succeed_max = 0
  @spans.each do |span|
    # NOTE @spans.map(&:write_time).sort.last と同じことだけど、処理コストを軽くするためにループを共通化する
    write_time_max = span.write_time if write_time_max < span.write_time
    read_time_max = span.read_time if write_time_max < span.read_time
    time_taken_max = span.time_taken if span.succeed && time_taken_max < span.time_taken
    interval_from_previous_succeed_max = span.interval_from_previous_succeed if span.succeed && interval_from_previous_succeed_max < span.interval_from_previous_succeed
    external_input_time_max = span.external_input_time if span.succeed && external_input_time_max < span.external_input_time
  end

  # NOTE 今はGCを無効にしており、集計するまでもないのでコメントアウトにする. 今後GCを有効にしたバイパスをするかもしれないので残しておく
  gc_count = 0 # @spans.map(&:gc_count).sum
  gc_time = 0 # @spans.map(&:gc_time).sum

  # sorted_interval_from_previous_succeed = @spans.select(&:succeed).map(&:interval_from_previous_succeed).sort
  # interval_from_previous_succeed_max = sorted_interval_from_previous_succeed.last || 0
  interval_from_previous_succeed_p50 = 0 # percentile(sorted_list: sorted_interval_from_previous_succeed , percentile: 0.50)

  # sorted_read_time = @spans.map(&:read_time).sort
  read_time_p50 = 0 # percentile(sorted_list: sorted_read_time , percentile: 0.50)
  # read_time_max = sorted_read_time.last || 0

  # sorted_write_time = @spans.map(&:write_time).sort
  write_time_p50 = 0 # percentile(sorted_list: sorted_write_time , percentile: 0.50)
  # write_time_max = sorted_write_time.last || 0

  # sorted_time_taken = @spans.select(&:succeed).map(&:time_taken).sort
  time_taken_p50 = 0 # percentile(sorted_list: sorted_time_taken, percentile: 0.50)
  time_taken_p95 = 0 # percentile(sorted_list: sorted_time_taken, percentile: 0.95)
  time_taken_p99 = 0 # percentile(sorted_list: sorted_time_taken, percentile: 0.99)
  # time_taken_max = sorted_time_taken.last || 0

  # NOTE webに表示していないのでコメントアウト. デバッグ時に見ることがあるので残しておく
  total_read_error_count = 0 # @spans.map(&:read_error_count).sum
  total_write_error_count = 0 # @spans.map(&:write_error_count).sum

  # succeed_rate =
  #   if @spans.length.zero?
  #     0
  #   else
  #     succeed_rate = (sorted_time_taken.length / @spans.length.to_f).floor(3)
  #   end
  succeed_rate = 1 # Switchへの書き込みに失敗した時にretryしているので100%になるようになってる. succeedの個数をカウントコストを減らすためにハードコード

  PerformanceMetric.new(interval_from_previous_succeed_max,
                        interval_from_previous_succeed_p50,
                        write_time_max,
                        write_time_p50,
                        read_time_max,
                        read_time_p50,
                        time_taken_p50,
                        time_taken_p95,
                        time_taken_p99,
                        time_taken_max,
                        external_input_time_max,
                        total_read_error_count,
                        total_write_error_count,
                        gc_count,
                        gc_time,
                        succeed_rate)
end