lib/bigbench/configuration.rb in bigbench-0.0.1 vs lib/bigbench/configuration.rb in bigbench-0.0.2
- old
+ new
@@ -1,13 +1,14 @@
module BigBench
# The configuration is configured in the test reciepts and looks like this:
#
# BigBench.configure = {
- # :duration => 10.seconds,
- # :output => "test.ljson",
- # :threads => 20
+ # :duration => 10.seconds,
+ # :output => "test.ljson",
+ # :users => 20,
+ # :basic_auth => ['username', 'secret']
# }
#
# Single values can be set and retrieved like this:
#
# BigBench.config.duration = 20.minutes
@@ -17,26 +18,31 @@
#
# [duration*] How long will the benchmark take by default. This value can be overridden by every benchmark.
# [output*] The file where the results should be written to. Usually one takes the <tt>*.ljson</tt> format which is simply a file
# that contains a fully valid JSON object on every line. This makes it easy to process the results later on, because there's
# no need to parse the whole results JSON, which can get huge, at once.
- # [threads] How many threads execute the benchmarks. This can be overridden by every benchmark and defaults to <tt>1</tt>.
+ # [users] How many users execute the benchmarks concurrently. This can be overridden by every benchmark and defaults to <tt>1</tt>.
+ # [basic_auth] A basic authentication that is used by ALL requests. This can be overridden per fragment in every benchmark.
+ #
+ # BigBench.config.basic_auth = ['username', 'password']
+ #
module Configuration
# The main config object for BigBench. It allows config options to
# be added and forces some default values before it is <tt>valid?</tt>
class Config
attr_accessor :duration
attr_accessor :output
- attr_accessor :threads
+ attr_accessor :users
attr_accessor :mode
attr_accessor :bot_checks_every
+ attr_accessor :basic_auth
- VALIDATE_OPTIONS = [:duration, :output, :threads]
+ VALIDATE_OPTIONS = [:duration, :output, :users]
def initialize
- @threads, @duration, @mode, @bot_checks_every = 1, 1.second, :local, 1.minute
+ @users, @duration, @mode, @bot_checks_every = 1, 1.second, :local, 1.minute
end
def self.add_option(name)
attr_accessor name unless self.respond_to?(name)
end
@@ -79,12 +85,13 @@
end
# Configure the benchmark by supplying a hash of options like this:
#
# BigBench.configure = {
- # :duration => 10.seconds,
- # :output => "test.ljson",
- # :threads => 20
+ # :duration => 10.seconds,
+ # :output => "test.ljson",
+ # :users => 20,
+ # :basic_auth => ['username', 'secret']
# }
#
# Those values can then be set and retreived with <tt>BigBench.config.duration</tt>, ...
def self.configure=(config)
Configuration.configure=(config)
\ No newline at end of file