Class: Bench::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/bench9000/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



20
21
22
23
24
25
26
27
# File 'lib/bench9000/config.rb', line 20

def initialize
  @implementations = {}
  @implementation_groups = {}
  @benchmarks = {}
  @benchmark_groups = {}
  @fail_hard_exclusions = []
  @commands = {}
end

Instance Attribute Details

#benchmark_groupsObject (readonly)

Returns the value of attribute benchmark_groups.



16
17
18
# File 'lib/bench9000/config.rb', line 16

def benchmark_groups
  @benchmark_groups
end

#benchmarksObject (readonly)

Returns the value of attribute benchmarks.



15
16
17
# File 'lib/bench9000/config.rb', line 15

def benchmarks
  @benchmarks
end

#commandsObject (readonly)

Returns the value of attribute commands.



18
19
20
# File 'lib/bench9000/config.rb', line 18

def commands
  @commands
end

#fail_hard_exclusionsObject (readonly)

Returns the value of attribute fail_hard_exclusions.



17
18
19
# File 'lib/bench9000/config.rb', line 17

def fail_hard_exclusions
  @fail_hard_exclusions
end

#implementation_groupsObject (readonly)

Returns the value of attribute implementation_groups.



14
15
16
# File 'lib/bench9000/config.rb', line 14

def implementation_groups
  @implementation_groups
end

#implementationsObject (readonly)

Returns the value of attribute implementations.



13
14
15
# File 'lib/bench9000/config.rb', line 13

def implementations
  @implementations
end

Instance Method Details

#benchmark(name, file, flags = "") ⇒ Object



59
60
61
# File 'lib/bench9000/config.rb', line 59

def benchmark(name, file, flags="")
  @benchmarks[name] = Benchmark.new(name, file, flags)
end

#benchmark_group(name, *benchmarks) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/bench9000/config.rb', line 63

def benchmark_group(name, *benchmarks)
  @benchmark_groups[name] = Group.new(name, benchmarks.map { |b|
    benchmark = @benchmarks[b]

    if benchmark.nil?
      puts "unknown benchmark #{b} in group"
      exit
    end

    benchmark
  })
end

#binary(name, binary, flags = "") ⇒ Object



38
39
40
# File 'lib/bench9000/config.rb', line 38

def binary(name, binary, flags="")
  @implementations[name] = BinaryImplementation.new(name, binary, flags)
end

#command(name, &body) ⇒ Object



80
81
82
83
84
# File 'lib/bench9000/config.rb', line 80

def command(name, &body)
  command_class = Class.new(Commands::Command)
  command_class.class_eval(&body)
  @commands[name] = command_class
end

#default_benchmarks_dirObject



55
56
57
# File 'lib/bench9000/config.rb', line 55

def default_benchmarks_dir
  File.expand_path(File.dirname(@configuration_file_path))
end

#fails_hard(implementation, benchmark) ⇒ Object



76
77
78
# File 'lib/bench9000/config.rb', line 76

def fails_hard(implementation, benchmark)
  @fail_hard_exclusions.push([implementation, benchmark])
end

#implementation_group(name, *implementations) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/bench9000/config.rb', line 42

def implementation_group(name, *implementations)
  @implementation_groups[name] = Group.new(name, implementations.map { |i|
    implementation = @implementations[i]

    if implementation.nil?
      puts "unknown implementation #{i} in group"
      exit
    end

    implementation
  })
end

#load(file) ⇒ Object



29
30
31
32
# File 'lib/bench9000/config.rb', line 29

def load(file)
  @configuration_file_path = file
  eval File.read(file), binding, file, 1
end

#rbenv(name, version = name, flags = "") ⇒ Object



34
35
36
# File 'lib/bench9000/config.rb', line 34

def rbenv(name, version=name, flags="")
  @implementations[name] = RbenvImplementation.new(name, version, flags)
end