diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-09-05 14:58:34 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-09-05 14:58:34 +0200 |
commit | 227ee2ecb46f1609938a83ed82abde1a45ebe2eb (patch) | |
tree | 49e523792a1446a9b5dd1416489ed5af666f0a9b /actionpack | |
parent | de0e7507de826bf77fd57cc2a51e27388cb62ff7 (diff) | |
download | rails-227ee2ecb46f1609938a83ed82abde1a45ebe2eb.tar.gz rails-227ee2ecb46f1609938a83ed82abde1a45ebe2eb.tar.bz2 rails-227ee2ecb46f1609938a83ed82abde1a45ebe2eb.zip |
Use a more sensible resolution on the new millisecond benchmarks
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 4 | ||||
-rw-r--r-- | actionpack/lib/action_controller/benchmarking.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/benchmark_helper.rb | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 10ee29807d..cb61c8d2dd 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -6,11 +6,11 @@ * Changed logging format to be millisecond based and skip misleading stats [DHH]. Went from: - Completed in 0.10000 (4 reqs/sec) | Rendering: 0.40000 (40%) | DB: 0.04000 (4%) | 200 OK [http://example.com] + Completed in 0.10000 (4 reqs/sec) | Rendering: 0.04000 (40%) | DB: 0.00400 (4%) | 200 OK [http://example.com] ...to: - Completed in 100.00ms (View: 400.00, DB: 40.00) | 200 OK [http://example.com] + Completed in 100ms (View: 40, DB: 4) | 200 OK [http://example.com] * Add support for shallow nesting of routes. #838 [S. Brent Faulkner] diff --git a/actionpack/lib/action_controller/benchmarking.rb b/actionpack/lib/action_controller/benchmarking.rb index a2bd61889f..746894497c 100644 --- a/actionpack/lib/action_controller/benchmarking.rb +++ b/actionpack/lib/action_controller/benchmarking.rb @@ -24,7 +24,7 @@ module ActionController #:nodoc: if logger && logger.level == log_level result = nil seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield } - logger.add(log_level, "#{title} (#{('%.2f' % (seconds * 1000))}ms)") + logger.add(log_level, "#{title} (#{('%.1f' % (seconds * 1000))}ms)") result else yield @@ -69,7 +69,7 @@ module ActionController #:nodoc: logging_view = defined?(@view_runtime) logging_active_record = Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? - log_message = "Completed in #{sprintf("%.2f", seconds * 1000)}ms" + log_message = "Completed in #{sprintf("%.0f", seconds * 1000)}ms" if logging_view || logging_active_record log_message << " (" @@ -86,21 +86,21 @@ module ActionController #:nodoc: log_message << " [#{complete_request_uri rescue "unknown"}]" logger.info(log_message) - response.headers["X-Runtime"] = "#{sprintf("%.2f", seconds * 1000)}ms" + response.headers["X-Runtime"] = "#{sprintf("%.0f", seconds * 1000)}ms" else perform_action_without_benchmark end end def view_runtime - "View: %.2f" % (@view_runtime * 1000) + "View: %.0f" % (@view_runtime * 1000) end def active_record_runtime db_runtime = ActiveRecord::Base.connection.reset_runtime db_runtime += @db_rt_before_render if @db_rt_before_render db_runtime += @db_rt_after_render if @db_rt_after_render - "DB: %.2f" % (db_runtime * 1000) + "DB: %.0f" % (db_runtime * 1000) end end end diff --git a/actionpack/lib/action_view/helpers/benchmark_helper.rb b/actionpack/lib/action_view/helpers/benchmark_helper.rb index 2401338896..bd72cda700 100644 --- a/actionpack/lib/action_view/helpers/benchmark_helper.rb +++ b/actionpack/lib/action_view/helpers/benchmark_helper.rb @@ -15,7 +15,7 @@ module ActionView # <%= expensive_files_operation %> # <% end %> # - # That would add something like "Process data files (345.23ms)" to the log, + # That would add something like "Process data files (345.2ms)" to the log, # which you can then use to compare timings when optimizing your code. # # You may give an optional logger level as the second argument @@ -23,7 +23,7 @@ module ActionView def benchmark(message = "Benchmarking", level = :info) if controller.logger seconds = Benchmark.realtime { yield } - controller.logger.send(level, "#{message} (#{'%.2f' % (seconds * 1000)}ms)") + controller.logger.send(level, "#{message} (#{'%.1f' % (seconds * 1000)}ms)") else yield end |