Class: ActiveSupport::Testing::Performance::Benchmarker
- Inherits:
-
Performer
show all
- Defined in:
- lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb
Instance Method Summary
collapse
Methods inherited from Performer
#initialize, #report
Instance Method Details
#environment ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb', line 125
def environment
unless defined? @env
app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/
rails = Rails::VERSION::STRING
if File.directory?('vendor/rails/.git')
Dir.chdir('vendor/rails') do
rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
end
end
ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
@env = [app, rails, ruby, RUBY_PLATFORM] * ','
end
@env
end
|
117
118
119
120
121
122
123
|
# File 'lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb', line 117
def record
avg = @metric.total / profile_options[:runs].to_i
now = Time.now.utc.xmlschema
with_output_file do |file|
file.puts "#{avg},#{now},#{environment}"
end
end
|
112
113
114
115
|
# File 'lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb', line 112
def run
profile_options[:runs].to_i.times { run_test(@metric, :benchmark) }
@total = @metric.total
end
|