Class: LLMBench::ResultsFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_bench/results_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(print_result: false) ⇒ ResultsFormatter

Returns a new instance of ResultsFormatter.



7
8
9
# File 'lib/llm_bench/results_formatter.rb', line 7

def initialize(print_result: false)
  @print_result = print_result
end

Instance Method Details

#display_cycle_summary(results) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/llm_bench/results_formatter.rb', line 42

def display_cycle_summary(results)
  successful = results.select { |r| r[:success] }
  failed = results.reject { |r| r[:success] }

  puts "  #{Colors.success("Completed: #{successful.length} successful")}, #{Colors.error("#{failed.length} failed")}"

  if successful.any?
    avg_tps = successful.map { |r| r[:tokens_per_second] }.sum / successful.length
    puts "  #{Colors.metric("Average tokens/sec: #{avg_tps.round(2)}")}"
  end

  puts "  #{Colors.error("Failed: #{failed.map { |f| "#{f[:provider]}/#{f[:model]}" }.join(", ")}")}" if failed.any?

  display_individual_results(results) if results.any?
end

#display_results_table(results) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/llm_bench/results_formatter.rb', line 11

def display_results_table(results)
  sorted_results = results.sort_by { |r| -r[:tokens_per_second] }

  provider_width = calculate_column_width(sorted_results, :provider)
  model_width = calculate_column_width(sorted_results, :model)
  tokens_width = 12
  tps_width = 15

  header, separator = build_table_header(provider_width:, model_width:, tokens_width:, tps_width:)

  puts Colors.header(header)
  puts Colors.border(separator)

  display_table_rows(sorted_results, provider_width:, model_width:, tokens_width:, tps_width:)
  puts
end

#display_summary(results) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/llm_bench/results_formatter.rb', line 28

def display_summary(results)
  successful = results.select { |r| r[:success] }
  failed = results.reject { |r| r[:success] }

  puts Colors.header("=== Summary ===")
  puts Colors.info("Total benchmarks: #{results.length}")
  puts Colors.success("Successful: #{successful.length}")
  puts Colors.error("Failed: #{failed.length}")

  display_performance_metrics(successful) if successful.any?

  display_failed_benchmarks(failed) if failed.any?
end