Class: BenchmarkSpec
- Inherits:
-
Hash
- Object
- Hash
- BenchmarkSpec
- Defined in:
- lib/railsbench/benchmark_specs.rb
Constant Summary collapse
- READERS =
%w(uri method post_data query_string new_session action controller session_data xhr raw_data)
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, hash) ⇒ BenchmarkSpec
constructor
A new instance of BenchmarkSpec.
- #inspect ⇒ Object
Constructor Details
#initialize(name, hash) ⇒ BenchmarkSpec
13 14 15 16 |
# File 'lib/railsbench/benchmark_specs.rb', line 13 def initialize(name, hash) super(hash) @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/railsbench/benchmark_specs.rb', line 6 def name @name end |
Class Method Details
.load(name, file_name = nil) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/railsbench/benchmark_specs.rb', line 23 def load(name, file_name = nil) unless file_name file_name = ENV['RAILS_ROOT'] + "/config/benchmarks.yml" end @@specs = YAML::load(ERB.new(IO.read(file_name)).result) raise "There is no benchmark named '#{name}'" unless @@specs[name] parse(@@specs, name) end |
.parse(specs, name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/railsbench/benchmark_specs.rb', line 32 def parse(specs, name) spec = specs[name] if spec.is_a?(String) spec.split(/, */).collect!{ |n| parse(specs, n) }.flatten elsif spec.is_a?(Hash) [ BenchmarkSpec.new(name,spec) ] elsif spec.is_a?(Array) spec.collect{|n| parse(specs, n)}.flatten else raise "oops: unknown entry type in benchmark specification" end end |
Instance Method Details
#inspect ⇒ Object
18 19 20 |
# File 'lib/railsbench/benchmark_specs.rb', line 18 def inspect "BenchmarkSpec(#{name},#{super})" end |