Skip to content

Commit 6718cc8

Browse files
Fix interval handling.
1 parent 334f925 commit 6718cc8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/memory/profiler/sampler.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ def stop
146146
# @parameter interval [Numeric] Seconds between samples.
147147
# @yields {|sample| ...} Called when a class shows significant growth.
148148
def run(interval: 60, &block)
149-
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
150-
151149
while true
150+
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
151+
152152
sample!(&block)
153153

154+
# Sleep for the remainder of the interval:
154155
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
155156
delta = interval - (now - start_time)
156157
sleep(delta) if delta > 0
157-
start_time = now
158158
end
159159
end
160160

releases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## Unreleased
4+
5+
- Fix sampler loop interval handling.
6+
37
## v1.1.12
48

59
- Use `rb_obj_id` for tracking object states to avoid compaction issues.

0 commit comments

Comments
 (0)