Permalink
Browse files

Fix fragment benchmark calls and limit timings to 5 decimals

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2142 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Sep 6, 2005
1 parent 291c667 commit f86276b305b88c657f8ec9f853010d33f49907e2
@@ -27,7 +27,7 @@ def benchmark(title, log_level = Logger::DEBUG, use_silence = true)
if logger && logger.level == log_level
result = nil
seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield }
- logger.add(log_level, "#{title} (#{sprintf("%f", seconds)})")
+ logger.add(log_level, "#{title} (#{'%.5f' % seconds})")
result
else
yield
@@ -283,7 +283,7 @@ def write_fragment(name, content, options = {})
return unless perform_caching
key = fragment_cache_key(name)
- benchmark "Cached fragment: #{key}" do
+ self.class.benchmark "Cached fragment: #{key}" do
fragment_cache_store.write(key, content, options)
end
@@ -294,7 +294,7 @@ def read_fragment(name, options = {})
return unless perform_caching
key, cache = fragment_cache_key(name), nil
- benchmark "Fragment hit: #{key}" do
+ self.class.benchmark "Fragment read: #{key}" do
cache = fragment_cache_store.read(key, options)
end
@@ -311,11 +311,11 @@ def expire_fragment(name, options = {})
key = fragment_cache_key(name)
if key.is_a?(Regexp)
- benchmark "Expired fragments matching: #{key.source}" do
+ self.class.benchmark "Expired fragments matching: #{key.source}" do
fragment_cache_store.delete_matched(key, options)
end
else
- benchmark "Expired fragment: #{key}" do
+ self.class.benchmark "Expired fragment: #{key}" do
fragment_cache_store.delete(key, options)
end
end
@@ -720,7 +720,7 @@ def benchmark(title, use_silence = true)
if logger
result = nil
seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield }
- logger.info "#{title} (#{sprintf("%f", seconds)})"
+ logger.info "#{title} (#{'%.5f' % seconds)})"
result
else
yield

0 comments on commit f86276b

Please sign in to comment.