Class: Bench::Config
- Inherits:
-
Object
- Object
- Bench::Config
- Defined in:
- lib/bench9000/config.rb
Instance Attribute Summary collapse
-
#benchmark_groups ⇒ Object
readonly
Returns the value of attribute benchmark_groups.
-
#benchmarks ⇒ Object
readonly
Returns the value of attribute benchmarks.
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#fail_hard_exclusions ⇒ Object
readonly
Returns the value of attribute fail_hard_exclusions.
-
#implementation_groups ⇒ Object
readonly
Returns the value of attribute implementation_groups.
-
#implementations ⇒ Object
readonly
Returns the value of attribute implementations.
Instance Method Summary collapse
- #benchmark(name, file, flags = "") ⇒ Object
- #benchmark_group(name, *benchmarks) ⇒ Object
- #binary(name, binary, flags = "") ⇒ Object
- #command(name, &body) ⇒ Object
- #default_benchmarks_dir ⇒ Object
- #fails_hard(implementation, benchmark) ⇒ Object
- #implementation_group(name, *implementations) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load(file) ⇒ Object
- #rbenv(name, version = name, flags = "") ⇒ Object
Constructor Details
#initialize ⇒ Config
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_groups ⇒ Object (readonly)
Returns the value of attribute benchmark_groups.
16 17 18 |
# File 'lib/bench9000/config.rb', line 16 def benchmark_groups @benchmark_groups end |
#benchmarks ⇒ Object (readonly)
Returns the value of attribute benchmarks.
15 16 17 |
# File 'lib/bench9000/config.rb', line 15 def benchmarks @benchmarks end |
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
18 19 20 |
# File 'lib/bench9000/config.rb', line 18 def commands @commands end |
#fail_hard_exclusions ⇒ Object (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_groups ⇒ Object (readonly)
Returns the value of attribute implementation_groups.
14 15 16 |
# File 'lib/bench9000/config.rb', line 14 def implementation_groups @implementation_groups end |
#implementations ⇒ Object (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_dir ⇒ Object
55 56 57 |
# File 'lib/bench9000/config.rb', line 55 def default_benchmarks_dir File.(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 |