bench_bloc 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2970be47e52ee530bbb07311f9803822b131b622387a92ed7466c9aec3b0ba36
4
- data.tar.gz: 9f08eee57d653e12b434cb4cd5e1898a46d528ac297ec030ddcc469e889b3d56
3
+ metadata.gz: 339f07511f017128a7c7142b2c996c0a1130336dbbcbe23896d8eb48205d01b8
4
+ data.tar.gz: afa0caf488fd3784a1a73f1b392ebf08b72a5da194c182111ebfb9b71e63f0a6
5
5
  SHA512:
6
- metadata.gz: a89f3492876b64adca86fbb6e668a047f5e39d2441965edf5f6213061fe99608264aa750c775626bb94cea94d13dc4874216d6ceb89876da057fdc08127a7086
7
- data.tar.gz: 3387d9b7090682d90dedf1607ac3320e3f1d46287a12acda57ee884cc15b1723897831968d6a84f27b59571755a5c0c6f6b1581b244cbedc4371ac61a61b4f3d
6
+ metadata.gz: 3b0126270b0c82e7d67d21bfe49e751cd0d36cd38cef8b9e2e4cf46546ac290c54ca7210702647a371db8f309a201268b257afcfa4d64c0f53318b10e3221665
7
+ data.tar.gz: fe4dd940274998f9aa3d007a6e88a88925dc87fff74e086f94efb0d9baf2eaacf45f3c9009ea27156853373c50ae1370dfbb5c874cd20699174483b3b6a1d958
@@ -0,0 +1 @@
1
+ 2.6.3
@@ -1,17 +1,124 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bench_bloc (0.1.13)
4
+ bench_bloc (0.1.14)
5
+ ruby-prof
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ actioncable (6.0.2.1)
11
+ actionpack (= 6.0.2.1)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.2.1)
15
+ actionpack (= 6.0.2.1)
16
+ activejob (= 6.0.2.1)
17
+ activerecord (= 6.0.2.1)
18
+ activestorage (= 6.0.2.1)
19
+ activesupport (= 6.0.2.1)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.2.1)
22
+ actionpack (= 6.0.2.1)
23
+ actionview (= 6.0.2.1)
24
+ activejob (= 6.0.2.1)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
27
+ actionpack (6.0.2.1)
28
+ actionview (= 6.0.2.1)
29
+ activesupport (= 6.0.2.1)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.2.1)
35
+ actionpack (= 6.0.2.1)
36
+ activerecord (= 6.0.2.1)
37
+ activestorage (= 6.0.2.1)
38
+ activesupport (= 6.0.2.1)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.2.1)
41
+ activesupport (= 6.0.2.1)
42
+ builder (~> 3.1)
43
+ erubi (~> 1.4)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.2.1)
47
+ activesupport (= 6.0.2.1)
48
+ globalid (>= 0.3.6)
49
+ activemodel (6.0.2.1)
50
+ activesupport (= 6.0.2.1)
51
+ activerecord (6.0.2.1)
52
+ activemodel (= 6.0.2.1)
53
+ activesupport (= 6.0.2.1)
54
+ activestorage (6.0.2.1)
55
+ actionpack (= 6.0.2.1)
56
+ activejob (= 6.0.2.1)
57
+ activerecord (= 6.0.2.1)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.2.1)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (>= 0.7, < 2)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ zeitwerk (~> 2.2)
65
+ builder (3.2.4)
9
66
  coderay (1.1.2)
67
+ concurrent-ruby (1.1.5)
68
+ crass (1.0.6)
10
69
  diff-lcs (1.3)
70
+ erubi (1.9.0)
71
+ globalid (0.4.2)
72
+ activesupport (>= 4.2.0)
73
+ i18n (1.8.2)
74
+ concurrent-ruby (~> 1.0)
75
+ loofah (2.4.0)
76
+ crass (~> 1.0.2)
77
+ nokogiri (>= 1.5.9)
78
+ mail (2.7.1)
79
+ mini_mime (>= 0.1.1)
80
+ marcel (0.3.3)
81
+ mimemagic (~> 0.3.2)
11
82
  method_source (0.9.2)
83
+ mimemagic (0.3.3)
84
+ mini_mime (1.0.2)
85
+ mini_portile2 (2.4.0)
86
+ minitest (5.14.0)
87
+ nio4r (2.5.2)
88
+ nokogiri (1.10.7)
89
+ mini_portile2 (~> 2.4.0)
12
90
  pry (0.12.2)
13
91
  coderay (~> 1.1.0)
14
92
  method_source (~> 0.9.0)
93
+ rack (2.1.1)
94
+ rack-test (1.1.0)
95
+ rack (>= 1.0, < 3)
96
+ rails (6.0.2.1)
97
+ actioncable (= 6.0.2.1)
98
+ actionmailbox (= 6.0.2.1)
99
+ actionmailer (= 6.0.2.1)
100
+ actionpack (= 6.0.2.1)
101
+ actiontext (= 6.0.2.1)
102
+ actionview (= 6.0.2.1)
103
+ activejob (= 6.0.2.1)
104
+ activemodel (= 6.0.2.1)
105
+ activerecord (= 6.0.2.1)
106
+ activestorage (= 6.0.2.1)
107
+ activesupport (= 6.0.2.1)
108
+ bundler (>= 1.3.0)
109
+ railties (= 6.0.2.1)
110
+ sprockets-rails (>= 2.0.0)
111
+ rails-dom-testing (2.0.3)
112
+ activesupport (>= 4.2.0)
113
+ nokogiri (>= 1.6)
114
+ rails-html-sanitizer (1.3.0)
115
+ loofah (~> 2.3)
116
+ railties (6.0.2.1)
117
+ actionpack (= 6.0.2.1)
118
+ activesupport (= 6.0.2.1)
119
+ method_source
120
+ rake (>= 0.8.7)
121
+ thor (>= 0.20.3, < 2.0)
15
122
  rake (10.5.0)
16
123
  rspec (3.9.0)
17
124
  rspec-core (~> 3.9.0)
@@ -25,17 +132,43 @@ GEM
25
132
  rspec-mocks (3.9.1)
26
133
  diff-lcs (>= 1.2.0, < 2.0)
27
134
  rspec-support (~> 3.9.0)
135
+ rspec-rails (3.9.0)
136
+ actionpack (>= 3.0)
137
+ activesupport (>= 3.0)
138
+ railties (>= 3.0)
139
+ rspec-core (~> 3.9.0)
140
+ rspec-expectations (~> 3.9.0)
141
+ rspec-mocks (~> 3.9.0)
142
+ rspec-support (~> 3.9.0)
28
143
  rspec-support (3.9.2)
144
+ ruby-prof (1.1.0)
145
+ sprockets (4.0.0)
146
+ concurrent-ruby (~> 1.0)
147
+ rack (> 1, < 3)
148
+ sprockets-rails (3.2.1)
149
+ actionpack (>= 4.0)
150
+ activesupport (>= 4.0)
151
+ sprockets (>= 3.0.0)
152
+ thor (1.0.1)
153
+ thread_safe (0.3.6)
154
+ tzinfo (1.2.6)
155
+ thread_safe (~> 0.1)
156
+ websocket-driver (0.7.1)
157
+ websocket-extensions (>= 0.1.0)
158
+ websocket-extensions (0.1.4)
159
+ zeitwerk (2.2.2)
29
160
 
30
161
  PLATFORMS
31
162
  ruby
32
163
 
33
164
  DEPENDENCIES
34
165
  bench_bloc!
35
- bundler (~> 2.0.2)
166
+ bundler (~> 2.1.4)
36
167
  pry
168
+ rails
37
169
  rake (~> 10.0)
38
170
  rspec (~> 3.0)
171
+ rspec-rails
39
172
 
40
173
  BUNDLED WITH
41
- 2.0.2
174
+ 2.1.4
@@ -35,8 +35,11 @@ Gem::Specification.new do |spec|
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ["lib"]
37
37
 
38
- spec.add_development_dependency "bundler", "~> 2.0.2"
38
+ spec.add_development_dependency "bundler", "~> 2.1.4"
39
39
  spec.add_development_dependency "rake", "~> 10.0"
40
40
  spec.add_development_dependency "rspec", "~> 3.0"
41
41
  spec.add_development_dependency "pry"
42
+ spec.add_development_dependency "rails"
43
+ spec.add_development_dependency "rspec-rails"
44
+ spec.add_runtime_dependency "ruby-prof"
42
45
  end
@@ -3,11 +3,16 @@ require 'bench_bloc/bloc/bloc_namespace'
3
3
  require 'bench_bloc/bloc/bloc_task'
4
4
  require 'bench_bloc/formatter/formatter'
5
5
  require 'bench_bloc/formatter/benchmark'
6
+ require 'bench_bloc/formatter/ruby_prof'
6
7
  require 'bench_bloc/logger/logger'
8
+ require 'bench_bloc/logger/ruby_prof'
7
9
  require 'bench_bloc/railtie' if defined?(Rails)
10
+ require 'bench_bloc/raker/raker'
8
11
  require 'bench_bloc/version'
12
+ require 'ruby-prof'
9
13
 
10
14
 
11
15
  module BenchBloc
12
16
  class Error < StandardError; end
17
+ include BenchBloc::Raker
13
18
  end
@@ -12,7 +12,8 @@ module BenchBloc
12
12
  bloc_namespaces.push(
13
13
  Bloc::Namespace.new(
14
14
  :bench_bloc,
15
- bloc_hash
15
+ bloc_hash,
16
+ true
16
17
  )
17
18
  )
18
19
  end
@@ -27,13 +28,13 @@ module BenchBloc
27
28
  bench_bloc_namespace
28
29
  .bloc_namespaces
29
30
  .find { |bn| namespace_key == bn.namespace_key }
30
- end
31
+ end
31
32
 
32
33
  private
33
34
  def is_task? obj
34
35
  obj.keys.any?(:profile)
35
36
  end
36
-
37
+
37
38
  def bench_bloc_namespace
38
39
  bloc_namespaces[0]
39
40
  end
@@ -1,15 +1,15 @@
1
1
  module BenchBloc
2
2
  class Bloc::Namespace < BenchBloc::Bloc
3
- attr_reader :bloc_namespaces, :bloc_tasks, :namespace_key
4
- def initialize namespace_key, bloc_hash
3
+ attr_reader :bloc_namespaces, :bloc_tasks, :namespace_key, :add_all_task
4
+ def initialize namespace_key, bloc_hash, add_all_task=false
5
5
  super(bloc_hash)
6
6
  @namespace_key = namespace_key
7
- @bloc_namespaces, @bloc_tasks = [], []
7
+ @bloc_namespaces, @bloc_tasks, @add_all_task = [], [], add_all_task
8
8
  put_namespace
9
9
  end
10
10
 
11
11
  def put_namespace
12
- bloc_hash.keys.each do |bh_key|
12
+ bloc_hash.keys.each do |bh_key|
13
13
  if is_task? bloc_hash[bh_key]
14
14
  bloc_tasks.push(
15
15
  BenchBloc::Bloc::Task.new(
@@ -36,6 +36,7 @@ module BenchBloc
36
36
  bloc_namespaces.each do |bn|
37
37
  bn.rake_namespace
38
38
  end
39
+ put_all_task if @add_all_task
39
40
  end
40
41
  end
41
42
 
@@ -1,21 +1,33 @@
1
- require 'bench_bloc'
1
+ # require 'bench_bloc'
2
2
  module BenchBloc
3
3
  class Bloc::Task < BenchBloc::Bloc
4
- attr_reader :description,
5
- :label,
6
- :namespace,
7
- :profile,
8
- :title,
4
+ attr_reader :description,
5
+ :label,
6
+ :namespace,
7
+ :profile,
8
+ :title,
9
9
  :to_profile
10
-
10
+ :ruby_prof
11
+
11
12
  def initialize namespace, bloc_task
12
13
  super(bloc_task)
13
14
  @namespace = namespace
14
15
  parse_bloc_task bloc_task
15
16
  end
16
17
 
17
- # TODO: Put into a TaskRunner class
18
- def run_task
18
+ def rake_task
19
+ desc description
20
+ task namespace => :environment do
21
+ BenchBloc::Logger.new(run_benchmark, description).log_results
22
+ BenchBloc::Logger::RubyProf
23
+ .new(run_ruby_prof, description)
24
+ .log_results if @ruby_prof == true
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def run_benchmark
19
31
  Benchmark.bm do |x|
20
32
  [to_profile.call].flatten.each do |otp|
21
33
  x.report(label.call(otp)) do
@@ -25,23 +37,21 @@ module BenchBloc
25
37
  end
26
38
  end
27
39
 
28
- def rake_task
29
- desc description
30
- task namespace => :environment do
31
- BenchBloc::Logger.new(run_task, description).log_results
32
- # run ruby-prof
33
- # format_ruby_prof(run_ruby_prof(new_task[:prof], tp)) if @options[:ruby_prof] == true
40
+ def run_ruby_prof
41
+ rp_profile = RubyProf::Profile.new
42
+ result = rp_profile.profile do
43
+ @profile.call
34
44
  end
35
45
  end
36
46
 
37
- private
38
-
39
47
  def parse_bloc_task bloc_task
40
48
  @description = bloc_task[:description]
41
- @label = bloc_task[:label]
49
+ @label = bloc_task[:label]
42
50
  @profile = bloc_task[:profile]
43
51
  @title = bloc_task[:title]
44
52
  @to_profile = bloc_task[:to_profile]
53
+ @ruby_prof = bloc_task[:ruby_prof] || false
45
54
  end
46
55
  end
56
+
47
57
  end
@@ -0,0 +1,7 @@
1
+ module BenchBloc
2
+ class Formatter::RubyProf < BenchBloc::Formatter
3
+ def format_results
4
+ results
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'ruby-prof'
2
+ module BenchBloc
3
+ class Logger::RubyProf < BenchBloc::Logger
4
+ def log_results
5
+ formatted_results = BenchBloc::Formatter::RubyProf
6
+ .new(results, title)
7
+ .format_results
8
+ write_to_log formatted_results
9
+ end
10
+
11
+ def write_to_log results
12
+ if defined?(Rails)
13
+ printer = ::RubyProf::FlatPrinter.new(results)
14
+ File.open("#{Rails.root}/log/bench_bloc_ruby-prof.log", 'w') { |file|
15
+ printer.print(file)
16
+ }
17
+ else
18
+ printer = ::RubyProf::FlatPrinter.new(results)
19
+ File.open("log/bench_bloc_ruby-prof.log", "w") { |file|
20
+ printer.print(file)
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,55 +1,20 @@
1
- module BenchBloc
2
- class Raker
3
- def bench_tasks
4
- Rake.application.tasks.select do |task|
5
- task.name.starts_with?("bench_bloc") &&
6
- !task.name.ends_with?("_util") &&
7
- task.name != "bench_bloc:all"
8
- end
9
- end
10
-
11
- # def option_parser
12
- # OptionParser.new do |opts|
13
- # opts.banner = "Usage: rake bench_bloc:* [options]"
14
- # opts.on("-r", "--ruby-prof", "Print a RubyProf report") do |rp|
15
- # @options[:ruby_prof] = rp
16
- # end
17
- # end
18
- # end
19
-
20
- # def put_options_parser_task
21
- # desc "Options parser for bench tasks"
22
- # task parse_options_util: :environment do
23
- # @options = {}
24
- # option_parser.parse!
25
- # option_parser.parse!
26
- # end
27
- # end
28
-
29
- def put_clear_tests_task
30
- desc "Clear Tests"
31
- task clear_tests_util: :environment do
32
- at_exit do
33
- test_ts = Timesheet.where("general_remarks LIKE '%BENCHTEST%'")
34
- puts "Clearing #{test_ts.count} test timesheets"
35
- test_ts.destroy_all
36
- end
37
- end
38
- end
39
-
40
- def put_all_task
41
- desc "Run all benchmarks"
42
- task all: :environment do
43
- bench_tasks.each(&:execute)
44
- Rake::Task["bench_bloc:clear_tests_util"].invoke
45
- end
1
+ require 'rake'
2
+ module BenchBloc::Raker
3
+ include Rake::DSL
4
+ def bench_tasks
5
+ Rake.application.tasks.select do |task|
6
+ task.name.starts_with?("bench_bloc") &&
7
+ !task.name.ends_with?("_util") &&
8
+ task.name != "bench_bloc:all"
46
9
  end
10
+ end
47
11
 
48
- def add_bench_hooks
49
- bench_tasks.each do |task|
50
- Rake::Task[task.name]
51
- .enhance(['bench_bloc:parse_options_util', 'bench_bloc:clear_tests_util'])
52
- end
12
+ def put_all_task
13
+ desc "Run all benchmarks"
14
+ task all: :environment do
15
+ bench_tasks.each(&:execute)
16
+ Rake::Task["bench_bloc:clear_tests_util"].invoke
53
17
  end
54
18
  end
19
+
55
20
  end
@@ -13,5 +13,3 @@ BLOC_FILES.each do |f|
13
13
  bench_bloc.rake_bloc
14
14
  end
15
15
 
16
- # add_bench_hooks
17
-
@@ -1,3 +1,3 @@
1
1
  module BenchBloc
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bench_bloc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-18 00:00:00.000000000 Z
11
+ date: 2020-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.2
19
+ version: 2.1.4
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.2
26
+ version: 2.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,48 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-prof
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
69
111
  description: Use a hash syntax to automatically generate rake tasks which run benchmarks
70
112
  on given blocks of code
71
113
  email:
@@ -76,6 +118,7 @@ extra_rdoc_files: []
76
118
  files:
77
119
  - ".gitignore"
78
120
  - ".rspec"
121
+ - ".ruby-version"
79
122
  - ".travis.yml"
80
123
  - CODE_OF_CONDUCT.md
81
124
  - Gemfile
@@ -87,16 +130,15 @@ files:
87
130
  - bin/console
88
131
  - bin/setup
89
132
  - lib/bench_bloc.rb
90
- - lib/bench_bloc/bloc.rb
91
133
  - lib/bench_bloc/bloc/bloc.rb
92
134
  - lib/bench_bloc/bloc/bloc_namespace.rb
93
135
  - lib/bench_bloc/bloc/bloc_task.rb
94
- - lib/bench_bloc/bloc_namespace.rb
95
- - lib/bench_bloc/bloc_task.rb
96
136
  - lib/bench_bloc/formatter/benchmark.rb
97
137
  - lib/bench_bloc/formatter/formatter.rb
138
+ - lib/bench_bloc/formatter/ruby_prof.rb
98
139
  - lib/bench_bloc/helpers/ruby_prof_helpers.rb
99
140
  - lib/bench_bloc/logger/logger.rb
141
+ - lib/bench_bloc/logger/ruby_prof.rb
100
142
  - lib/bench_bloc/railtie.rb
101
143
  - lib/bench_bloc/raker/raker.rb
102
144
  - lib/bench_bloc/tasks/gen_bench_bloc.rake
@@ -1,42 +0,0 @@
1
- require 'rake'
2
- module BenchBloc
3
- # Responsible for generating rake tasks from a hash and/or creating child Blocs
4
- class Bloc
5
- include Rake::DSL
6
- attr_accessor :bloc_hash, :bloc_namespaces
7
- def initialize bloc_hash
8
- @bloc_hash, @bloc_namespaces = bloc_hash, []
9
- end
10
-
11
- def generate_bloc
12
- bloc_namespaces.push(
13
- Bloc::Namespace.new(
14
- :bench_bloc,
15
- bloc_hash
16
- )
17
- )
18
- end
19
-
20
- def rake_bloc
21
- bloc_namespaces.each do |bn|
22
- bn.rake_namespace
23
- end
24
- end
25
-
26
- def [](namespace_key)
27
- bench_bloc_namespace
28
- .bloc_namespaces
29
- .find { |bn| namespace_key == bn.namespace_key }
30
- end
31
-
32
- private
33
- def is_task? obj
34
- obj.keys.any?(:to_profile)
35
- end
36
-
37
- def bench_bloc_namespace
38
- bloc_namespaces[0]
39
- end
40
-
41
- end
42
- end
@@ -1,43 +0,0 @@
1
- module BenchBloc
2
- class Bloc::Namespace < BenchBloc::Bloc
3
- attr_reader :bloc_namespaces, :bloc_tasks, :namespace_key
4
- def initialize namespace_key, bloc_hash
5
- super(bloc_hash)
6
- @namespace_key = namespace_key
7
- @bloc_namespaces, @bloc_tasks = [], []
8
- put_namespace
9
- end
10
-
11
- def put_namespace
12
- bloc_hash.keys.each do |bh_key|
13
- if is_task? bloc_hash[bh_key]
14
- bloc_tasks.push(
15
- BenchBloc::Bloc::Task.new(
16
- bh_key,
17
- bloc_hash[bh_key]
18
- )
19
- )
20
- else
21
- bloc_namespaces.push(
22
- Bloc::Namespace.new(
23
- bh_key,
24
- bloc_hash[bh_key]
25
- )
26
- )
27
- end
28
- end
29
- end
30
-
31
- def rake_namespace
32
- namespace namespace_key do
33
- bloc_tasks.each do |bt|
34
- bt.rake_task
35
- end
36
- bloc_namespaces.each do |bn|
37
- bn.rake_namespace
38
- end
39
- end
40
- end
41
-
42
- end
43
- end
@@ -1,37 +0,0 @@
1
- module BenchBloc
2
- class Bloc::Task < BenchBloc::Bloc
3
- attr_reader :description,
4
- :label,
5
- :namespace,
6
- :profile,
7
- :title,
8
- :to_profile
9
-
10
- def initialize namespace, bloc_task
11
- super(bloc_task)
12
- @namespace = namespace
13
- parse_bloc_task bloc_task
14
- end
15
-
16
- def rake_task
17
- desc description
18
- task namespace => :environment do
19
- to_profs = [to_profile.call].flatten
20
- bm_results = bm_run_results self, to_profs
21
- bm_log_results bm_results, description
22
- # run ruby-prof
23
- # format_ruby_prof(run_ruby_prof(new_task[:prof], tp)) if @options[:ruby_prof] == true
24
- end
25
- end
26
-
27
- private
28
-
29
- def parse_bloc_task bloc_task
30
- @description = bloc_task[:description]
31
- @label = bloc_task[:label]
32
- @profile = bloc_task[:profile]
33
- @title = bloc_task[:title]
34
- @to_profile = bloc_task[:to_profile]
35
- end
36
- end
37
- end