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

yangxing_star · 2015年07月05日 · 最后由 yangxing_star 回复于 2015年07月06日 · 1695 次阅读
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

需要 登录 后方可回复, 如果你还没有账号请 注册新账号