Class: LogStash::PerformanceMeter::Core
- Inherits:
-
Object
- Object
- LogStash::PerformanceMeter::Core
- Defined in:
- lib/lsperfm/core.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#install_path ⇒ Object
readonly
Returns the value of attribute install_path.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
-
#initialize(definition, install_path, config = '', runner = LogStash::PerformanceMeter::Runner) ⇒ Core
constructor
A new instance of Core.
- #run(debug = false, headers = false) ⇒ Object
Constructor Details
#initialize(definition, install_path, config = '', runner = LogStash::PerformanceMeter::Runner) ⇒ Core
Returns a new instance of Core.
12 13 14 15 16 17 |
# File 'lib/lsperfm/core.rb', line 12 def initialize(definition, install_path, config='', runner = LogStash::PerformanceMeter::Runner) @definition = definition @install_path = install_path @runner = runner @config = load_config(config) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/lsperfm/core.rb', line 10 def config @config end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
10 11 12 |
# File 'lib/lsperfm/core.rb', line 10 def definition @definition end |
#install_path ⇒ Object (readonly)
Returns the value of attribute install_path.
10 11 12 |
# File 'lib/lsperfm/core.rb', line 10 def install_path @install_path end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
10 11 12 |
# File 'lib/lsperfm/core.rb', line 10 def runner @runner end |
Instance Method Details
#run(debug = false, headers = false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lsperfm/core.rb', line 19 def run(debug=false, headers=false) tests = load_tests(definition) lines = (headers ? ["name, #{runner.headers.join(',')}"] : []) reporter = LogStash::PerformanceMeter::Reporter.new.start tests.each do |test| events = test[:events].to_i time = test[:time].to_i manager = runner.new(find_test_config(test[:config]), debug, install_path) metrics = manager.run(events, time, runner.read_input_file(find_test_input(test[:input]))) lines << formatter(test[:name], metrics) end lines rescue Errno::ENOENT => e raise ConfigException.new(e) ensure reporter.stop if reporter end |