Class: CelluloidBenchmark::Runner
- Inherits:
-
Object
- Object
- CelluloidBenchmark::Runner
- Defined in:
- lib/celluloid_benchmark/runner.rb
Overview
Run a scenario in several Visitors and return a BenchmarkRun
Class Method Summary collapse
- .run(args) ⇒ Object
- .run_sessions(benchmark_run, duration, visitors, target) ⇒ Object
- .visitors_count(count) ⇒ Object
Class Method Details
.run(args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/celluloid_benchmark/runner.rb', line 11 def self.run(args) session = args[:session] || "session.rb" visitors = args[:visitors] || visitors_count(args[:visitors]) duration = (args[:duration] || 20).to_f target = args[:target] require File.(session) VisitorGroup.run! visitors = visitors_count(visitors) benchmark_run = Celluloid::Actor[:benchmark_run] benchmark_run.visitors = visitors benchmark_run.mark_start futures = run_sessions(benchmark_run, duration, visitors, Target.new_from_key(target)) futures.map(&:value) benchmark_run.mark_end benchmark_run end |
.run_sessions(benchmark_run, duration, visitors, target) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/celluloid_benchmark/runner.rb', line 34 def self.run_sessions(benchmark_run, duration, visitors, target) pool = Celluloid::Actor[:visitor_pool] futures = [] visitors.times do futures << pool.future.run_session(benchmark_run, duration, target) end futures end |
.visitors_count(count) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/celluloid_benchmark/runner.rb', line 43 def self.visitors_count(count) if count count = count.to_i else count = Visitor.pool.size - 2 end if count > 1 count else 1 end end |