Changeset 2140
- Timestamp:
- 09/06/05 16:48:18 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/benchmarking.rb (modified) (2 diffs)
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r2131 r2140 1 1 *SVN* 2 3 * Added ActionController::Base.benchmark and ActionController::Base.silence to allow for easy benchmarking and turning off the log 2 4 3 5 * Updated vendor copy of html-scanner to support better xml parsing trunk/actionpack/lib/action_controller/benchmarking.rb
r2039 r2140 7 7 def self.append_features(base) 8 8 super 9 base.class_eval { 9 base.extend(ClassMethods) 10 base.class_eval do 10 11 alias_method :perform_action_without_benchmark, :perform_action 11 12 alias_method :perform_action, :perform_action_with_benchmark … … 13 14 alias_method :render_without_benchmark, :render 14 15 alias_method :render, :render_with_benchmark 15 } 16 end 17 end 18 19 module ClassMethods 20 # Log and benchmark the workings of a single block and silence whatever logging that may have happened inside it 21 # (unless <tt>use_silence</tt> is set to false). 22 def benchmark(title, use_silence = true) 23 if logger 24 result = nil 25 seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield } 26 logger.info "#{title} (#{sprintf("%f", seconds)})" 27 result 28 else 29 yield 30 end 31 end 32 33 # Silences the logger for the duration of the block. 34 def silence 35 old_logger_level, logger.level = logger.level, Logger::ERROR if logger 36 yield 37 ensure 38 logger.level = old_logger_level if logger 39 end 16 40 end 17 41 trunk/activerecord/CHANGELOG
r2105 r2140 1 1 *SVN* 2 3 * Added use_silence parameter to ActiveRecord::Base.benchmark that can be passed false to include all logging statements during the benchmark block 2 4 3 5 * Make sure the schema_info table is created before querying the current version #1903 trunk/activerecord/lib/active_record/base.rb
r2096 r2140 715 715 # project.milestones << Milestone.find(:all) 716 716 # end 717 def benchmark(title) 718 result = nil 719 seconds = Benchmark.realtime { result = silence { yield } } 720 logger.info "#{title} (#{sprintf("%f", seconds)})" if logger 721 return result 717 # 718 # The loggings of the multiple statements is turned off unless <tt>use_silence</tt> is set to false. 719 def benchmark(title, use_silence = true) 720 if logger 721 result = nil 722 seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield } 723 logger.info "#{title} (#{sprintf("%f", seconds)})" 724 result 725 else 726 yield 727 end 722 728 end 723 729