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
This commit is contained in:
commit
388a496443
|
@ -57,17 +57,9 @@ module Gitlab
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# THREAD_CPUTIME is not supported on OS X
|
def self.cpu_time
|
||||||
if Process.const_defined?(:CLOCK_THREAD_CPUTIME_ID)
|
Process
|
||||||
def self.cpu_time
|
.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :float_second)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the current real time in a given precision.
|
# Returns the current real time in a given precision.
|
||||||
|
|
|
@ -52,13 +52,13 @@ describe Gitlab::Metrics::System do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.cpu_time' do
|
describe '.cpu_time' do
|
||||||
it 'returns a Fixnum' do
|
it 'returns a Float' do
|
||||||
expect(described_class.cpu_time).to be_an(Float)
|
expect(described_class.cpu_time).to be_an(Float)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.real_time' do
|
describe '.real_time' do
|
||||||
it 'returns a Fixnum' do
|
it 'returns a Float' do
|
||||||
expect(described_class.real_time).to be_an(Float)
|
expect(described_class.real_time).to be_an(Float)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue