mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 22:57:40 +08:00
DEV: Seperate concerns of tracking GC stat from MethodProfiler
(#22921)
Why this change? This is a follow up to e8f7b62752a65e33aa1cee748fc966c4ad14b1ee. 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`.
This commit is contained in:

committed by
GitHub

parent
e8f7b62752
commit
773b22e8d0
18
spec/lib/gc_stat_instrumenter_spec.rb
Normal file
18
spec/lib/gc_stat_instrumenter_spec.rb
Normal file
@ -0,0 +1,18 @@
|
||||
# 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
|
Reference in New Issue
Block a user