Welcome to mirror list, hosted at ThFree Co, Russian Federation.

batch_metrics.rb « background_migration « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3e6d7ac3c9f79c7962c3cd6f0cc34d0b327c7e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Gitlab
  module Database
    module BackgroundMigration
      class BatchMetrics
        attr_reader :timings

        def initialize
          @timings = {}
        end

        def time_operation(label)
          start_time = monotonic_time

          yield

          timings_for_label(label) << monotonic_time - start_time
        end

        private

        def timings_for_label(label)
          timings[label] ||= []
        end

        def monotonic_time
          Gitlab::Metrics::System.monotonic_time
        end
      end
    end
  end
end