mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 15:33:43 +08:00
18 lines
422 B
Ruby
18 lines
422 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class GCStatInstrumenter
|
||
|
def self.instrument
|
||
|
start_gc_stat = GC.stat
|
||
|
yield
|
||
|
end_gc_stat = GC.stat
|
||
|
|
||
|
{
|
||
|
gc: {
|
||
|
time: (end_gc_stat[:time] - start_gc_stat[:time]) / 1000.0,
|
||
|
major_count: end_gc_stat[:major_gc_count] - start_gc_stat[:major_gc_count],
|
||
|
minor_count: end_gc_stat[:minor_gc_count] - start_gc_stat[:minor_gc_count],
|
||
|
},
|
||
|
}
|
||
|
end
|
||
|
end
|