Class: Serialbench::Runners::AsdfRunner

Inherits:
Base
  • Object
show all
Defined in:
lib/serialbench/runners/asdf_runner.rb

Defined Under Namespace

Classes: AsdfError

Instance Method Summary collapse

Constructor Details

#initialize(environment_config, environment_config_path) ⇒ AsdfRunner

Returns a new instance of AsdfRunner.



17
18
19
20
# File 'lib/serialbench/runners/asdf_runner.rb', line 17

def initialize(environment_config, environment_config_path)
  super
  validate_asdf_available
end

Instance Method Details

#benchmarkObject

Run benchmark

Raises:



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/serialbench/runners/asdf_runner.rb', line 45

def benchmark
  puts '🚀 Running benchmarks...'

  ruby_version = @environment_config.ruby_build_tag

  raise AsdfError, 'Benchmark run failed' unless run_benchmark(ruby_version)

  puts '✅ Completed 1 benchmark runs'
  puts "📁 Individual results are available in: results/runs/#{@environment_name}"
  puts '✅ ASDF benchmark completed successfully!'
  puts "Results saved to: results/runs/#{@environment_name}"
  puts "Generate site: serialbench benchmark build-site results/runs/#{@environment_name}"
end

#prepareObject

Prepare Ruby versions via ASDF



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/serialbench/runners/asdf_runner.rb', line 23

def prepare
  puts '💎 Preparing Ruby versions via ASDF...'

  ruby_version = @environment_config.ruby_build_tag
  installed_versions = get_installed_ruby_versions

  unless installed_versions.include?(ruby_version)
    if @environment_config.asdf&.auto_install
      install_missing_versions([ruby_version])
    else
      raise AsdfError,
            "Missing Ruby version: #{ruby_version}. Set auto_install: true to install automatically."
    end
  end

  # Install gems for the Ruby version
  install_gems_for_version(ruby_version)

  puts '✅ Ruby version is prepared with gems installed'
end