Class ActiveSupport::Testing::Benchmarker
In: vendor/rails/activesupport/lib/active_support/testing/performance.rb
Parent: Performer

Methods

Constants

HEADER = 'measurement,created_at,app,rails,ruby,platform'

Public Instance methods

[Source]

     # File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 125
125:         def environment
126:           unless defined? @env
127:             app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/
128: 
129:             rails = Rails::VERSION::STRING
130:             if File.directory?('vendor/rails/.git')
131:               Dir.chdir('vendor/rails') do
132:                 rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
133:               end
134:             end
135: 
136:             ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
137:             ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
138: 
139:             @env = [app, rails, ruby, RUBY_PLATFORM] * ','
140:           end
141: 
142:           @env
143:         end

[Source]

     # File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 117
117:         def record
118:           avg = @metric.total / profile_options[:runs].to_i
119:           now = Time.now.utc.xmlschema
120:           with_output_file do |file|
121:             file.puts "#{avg},#{now},#{environment}"
122:           end
123:         end

[Source]

     # File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 112
112:         def run
113:           profile_options[:runs].to_i.times { run_test(@metric, :benchmark) }
114:           @total = @metric.total
115:         end

Protected Instance methods

[Source]

     # File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 161
161:           def output_filename
162:             "#{super}.csv"
163:           end

[Source]

     # File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 148
148:           def with_output_file
149:             fname = output_filename
150: 
151:             if new = !File.exist?(fname)
152:               FileUtils.mkdir_p(File.dirname(fname))
153:             end
154: 
155:             File.open(fname, 'ab') do |file|
156:               file.puts(HEADER) if new
157:               yield file
158:             end
159:           end

[Validate]