Class: BenchBloc::Bloc::Task
- Inherits:
-
BenchBloc::Bloc
- Object
- BenchBloc::Bloc
- BenchBloc::Bloc::Task
- Defined in:
- lib/bench_bloc/bloc_task.rb,
lib/bench_bloc/bloc/bloc_task.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#to_profile ⇒ Object
readonly
Returns the value of attribute to_profile.
Attributes inherited from BenchBloc::Bloc
Instance Method Summary collapse
-
#initialize(namespace, bloc_task) ⇒ Task
constructor
A new instance of Task.
- #rake_task ⇒ Object
-
#run_task ⇒ Object
TODO: Put into a TaskRunner class.
Methods inherited from BenchBloc::Bloc
#[], #generate_bloc, #rake_bloc
Constructor Details
#initialize(namespace, bloc_task) ⇒ Task
Returns a new instance of Task.
10 11 12 13 14 |
# File 'lib/bench_bloc/bloc_task.rb', line 10 def initialize namespace, bloc_task super(bloc_task) @namespace = namespace parse_bloc_task bloc_task end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/bench_bloc/bloc_task.rb', line 3 def description @description end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/bench_bloc/bloc_task.rb', line 3 def label @label end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
3 4 5 |
# File 'lib/bench_bloc/bloc_task.rb', line 3 def namespace @namespace end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
3 4 5 |
# File 'lib/bench_bloc/bloc_task.rb', line 3 def profile @profile end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/bench_bloc/bloc_task.rb', line 3 def title @title end |
#to_profile ⇒ Object (readonly)
Returns the value of attribute to_profile.
3 4 5 |
# File 'lib/bench_bloc/bloc_task.rb', line 3 def to_profile @to_profile end |
Instance Method Details
#rake_task ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bench_bloc/bloc_task.rb', line 16 def rake_task desc description task namespace => :environment do to_profs = [to_profile.call].flatten bm_results = bm_run_results self, to_profs bm_log_results bm_results, description # run ruby-prof # format_ruby_prof(run_ruby_prof(new_task[:prof], tp)) if @options[:ruby_prof] == true end end |
#run_task ⇒ Object
TODO: Put into a TaskRunner class
18 19 20 21 22 23 24 25 26 |
# File 'lib/bench_bloc/bloc/bloc_task.rb', line 18 def run_task Benchmark.bm do |x| [to_profile.call].flatten.each do |otp| x.report(label.call(otp)) do profile.call(otp) end end end end |