mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
773b22e8d0
Why this change?
This is a follow up to e8f7b62752
.
Tracking of GC stats didn't really belong in the `MethodProfiler` class
so we want to extract that concern into its own class.
As part of this PR, the `track_gc_stat_per_request` site setting has
also been renamed to `instrument_gc_stat_per_request`.
19 lines
559 B
Ruby
19 lines
559 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe GCStatInstrumenter do
|
|
describe ".instrument" do
|
|
it "returns a hash with the GC time, major and minor GC count for executing the given block" do
|
|
result =
|
|
described_class.instrument do
|
|
GC.start(full_mark: true) # Major GC
|
|
GC.start(full_mark: false) # Minor GC
|
|
end
|
|
|
|
expect(result[:gc]).to be_present
|
|
expect(result[:gc][:time]).to be >= 0.0
|
|
expect(result[:gc][:major_count]).to eq(1)
|
|
expect(result[:gc][:minor_count]).to eq(1)
|
|
end
|
|
end
|
|
end
|