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.
154 155 156 157 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 154 def initialize(*args) super @supported = @metric.respond_to?('measure') end |
Instance Method Details
#environment ⇒ Object
174 175 176 177 178 179 180 181 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 174 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
166 167 168 169 170 171 172 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 166 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
159 160 161 162 163 164 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 159 def run return unless @supported [:runs].to_i.times { run_test(@metric, :benchmark) } @total = @metric.total end |