Class: ActiveSupport::Testing::Performance::Benchmarker
- Defined in:
- lib/rails/perftest/active_support/testing/performance.rb
Instance Method Summary collapse
- #environment ⇒ Object
-
#initialize(*args) ⇒ Benchmarker
constructor
A new instance of Benchmarker.
- #record ⇒ Object
- #run ⇒ Object
Methods inherited from Performer
Constructor Details
#initialize(*args) ⇒ Benchmarker
Returns a new instance of Benchmarker.
156 157 158 159 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 156 def initialize(*args) super @supported = @metric.respond_to?('measure') end |
Instance Method Details
#environment ⇒ Object
176 177 178 179 180 181 182 183 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 176 def environment @env ||= [].tap do |env| env << "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/ env << rails_version if defined?(Rails::VERSION::STRING) env << "#{RUBY_ENGINE}-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}" env << RUBY_PLATFORM end.join(',') end |
#record ⇒ Object
168 169 170 171 172 173 174 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 168 def record avg = @metric.total / [:runs].to_i now = Time.now.utc.xmlschema with_output_file do |file| file.puts "#{avg},#{now},#{environment}" end end |
#run ⇒ Object
161 162 163 164 165 166 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 161 def run return unless @supported [:runs].to_i.times { run_test(@metric, :benchmark) } @total = @metric.total end |