diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-19 14:33:58 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-24 12:57:21 +0300 |
commit | 97f8c6279fc39c4bad87bb880eba04802f6d351d (patch) | |
tree | ef1eac455f8529ae4e35f3b286e225e556f148ee /lib | |
parent | 31a34b591731eb8997da4844287d7c31e3686454 (diff) |
Added total query time to Sherlock
This makes it easier to see if a problem is caused by slow queries or
slow Ruby code (unrelated to any SQL queries that might be used).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/sherlock/transaction.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab/sherlock/transaction.rb b/lib/gitlab/sherlock/transaction.rb index d87a4c9bb4a..3489fb251b6 100644 --- a/lib/gitlab/sherlock/transaction.rb +++ b/lib/gitlab/sherlock/transaction.rb @@ -36,6 +36,11 @@ module Gitlab @duration ||= started_at && finished_at ? finished_at - started_at : 0 end + # Returns the total query duration in seconds. + def query_duration + @query_duration ||= @queries.map { |q| q.duration }.inject(:+) / 1000.0 + end + def to_param @id end |