mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-24 20:16:08 +10:00
Use clock_gettime for all performance timestamps
This MR adjusts the performance monitoring code to use `Process.clock_gettime` (thus `clock_gettime(3)`) instead of `Time.now`.
Using `Time.now` / `Time.new` adds more overhead than `Process.clock_gettime`, it also doesn't provide a way of getting timestamps in nanoseconds (which `Process.clock_gettime` does allow).
See merge request !4899
(cherry picked from commit 53ad9522c4)
48 lines
1.1 KiB
Ruby
48 lines
1.1 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Gitlab::Metrics::System do
|
|
if File.exist?('/proc')
|
|
describe '.memory_usage' do
|
|
it "returns the process' memory usage in bytes" do
|
|
expect(described_class.memory_usage).to be > 0
|
|
end
|
|
end
|
|
|
|
describe '.file_descriptor_count' do
|
|
it 'returns the amount of open file descriptors' do
|
|
expect(described_class.file_descriptor_count).to be > 0
|
|
end
|
|
end
|
|
else
|
|
describe '.memory_usage' do
|
|
it 'returns 0.0' do
|
|
expect(described_class.memory_usage).to eq(0.0)
|
|
end
|
|
end
|
|
|
|
describe '.file_descriptor_count' do
|
|
it 'returns 0' do
|
|
expect(described_class.file_descriptor_count).to eq(0)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '.cpu_time' do
|
|
it 'returns a Float' do
|
|
expect(described_class.cpu_time).to be_an_instance_of(Float)
|
|
end
|
|
end
|
|
|
|
describe '.real_time' do
|
|
it 'returns a Float' do
|
|
expect(described_class.real_time).to be_an_instance_of(Float)
|
|
end
|
|
end
|
|
|
|
describe '.monotonic_time' do
|
|
it 'returns a Float' do
|
|
expect(described_class.monotonic_time).to be_an_instance_of(Float)
|
|
end
|
|
end
|
|
end
|