Commit 388a4964 authored by Stan Hu's avatar Stan Hu

Merge branch '63874-use-process-cpu-time-instead-of-thread-for-cpu-metrics' into 'master'

Use PROCESS_CPUTIME_ID for cpu time metrics

Closes #63874

See merge request gitlab-org/gitlab-ce!30166
parents 638c8465 447ac5f9
......@@ -57,17 +57,9 @@ module Gitlab
end
end
# THREAD_CPUTIME is not supported on OS X
if Process.const_defined?(:CLOCK_THREAD_CPUTIME_ID)
def self.cpu_time
Process
.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :float_second)
end
else
def self.cpu_time
Process
.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :float_second)
end
def self.cpu_time
Process
.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :float_second)
end
# Returns the current real time in a given precision.
......
......@@ -52,13 +52,13 @@ describe Gitlab::Metrics::System do
end
describe '.cpu_time' do
it 'returns a Fixnum' do
it 'returns a Float' do
expect(described_class.cpu_time).to be_an(Float)
end
end
describe '.real_time' do
it 'returns a Fixnum' do
it 'returns a Float' do
expect(described_class.real_time).to be_an(Float)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment