Rails Grape ActiveRecord::RuntimeRegistry.sql_runtime sql 运行时间 累加问题

yangxing_star · July 05, 2015 · Last by yangxing_star replied at July 06, 2015 · 1696 hits
before do
  puts ActiveRecord::RuntimeRegistry.sql_runtime
end

after do
    db_runtime = ActiveRecord::RuntimeRegistry.sql_runtime
    Rails.logger.info("... ActiveRecord: #{db_runtime}ms")
end

db_runtime 时间总是上次执行的时间加上当前运行的时间,如何可以获取到当前一个请求的 db_runtime?

ActiveRecord::LogSubscriber.reset_runtime

You need to Sign in before reply, if you don't have an account, please Sign up first.