format :html do view :core do |args| oldmem = session[:memory] session[:memory] = newmem = card.profile_memory stats = %{ #{ if oldmem %{ } end }
Stat Value Action
cards #{ Card.where(:trash=>false).count }
trashed cards #{ Card.where(:trash=>true).count } #{link_to 'delete all', wagn_path( 'update/:all?task=empty_trash' )}
actions #{ Card::Action.count } #{link_to 'delete old', wagn_path( 'update/:all?task=delete_old_revisions' ) }
references #{ Card::Reference.count } #{link_to 'repair all', wagn_path( 'update/:all?task=repair_references' ) }
sessions #{ ActiveRecord::SessionStore::Session.count } delete older than #{ delete_sessions_link 1 } #{ delete_sessions_link 2 } #{ delete_sessions_link 3 } months
memory now #{ newmem }M #{link_to 'clear cache', wagn_path( 'update/:all?task=clear_cache' ) }
memory prev #{ oldmem }M
memory diff #{ newmem - oldmem }M
} end def delete_sessions_link months link_to months, wagn_path( "update/:all?task=delete_old_sessions&months=#{months}") end end def get_current_memory_usage `ps -o rss= -p #{Process.pid}`.to_i end def profile_memory(&block) before = get_current_memory_usage file, line, _ = caller[0].split(':') if block_given? instance_eval(&block) (get_current_memory_usage - before) / 1024 else before = 0 (get_current_memory_usage - before) / 1024 end.to_i end