class Puma::Benchmark::PrintResult
Public Instance Methods
call(result)
click to toggle source
# File lib/puma/benchmark/print_result.rb, line 4 def call(result) set_columns write_divider write_header write_divider result.each { |h| write_line(h) } write_divider end
set_columns()
click to toggle source
# File lib/puma/benchmark/print_result.rb, line 13 def set_columns @columns = {workers: {:label=>"No. of workers", :width=>15}, threads: {:label=>"No. of threads", :width=>15}, req_per_sec: {:label=>"No. of requests/sec", :width=>20}} end
write_divider()
click to toggle source
# File lib/puma/benchmark/print_result.rb, line 23 def write_divider puts "+-#{ @columns.map { |_,g| "-"*g[:width] }.join("-+-") }-+" end
write_header()
click to toggle source
# File lib/puma/benchmark/print_result.rb, line 19 def write_header puts "| #{ @columns.map { |_,g| g[:label].ljust(g[:width]) }.join(' | ') } |" end
write_line(h)
click to toggle source
# File lib/puma/benchmark/print_result.rb, line 27 def write_line(h) str = h.keys.map { |k| h[k].ljust(@columns[k][:width]) }.join(" | ") puts "| #{str} |" end