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
130 131 132 133 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 130 def initialize(*args) super @supported = @metric.respond_to?('measure') end |
Instance Method Details
#environment ⇒ Object
150 151 152 153 154 155 156 157 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 150 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
142 143 144 145 146 147 148 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 142 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
135 136 137 138 139 140 |
# File 'lib/rails/perftest/active_support/testing/performance.rb', line 135 def run return unless @supported [:runs].to_i.times { run_test(@metric, :benchmark) } @total = @metric.total end |