Skip to content

Commit 82ad86e

Browse files
authored
Merge pull request #9418 from AriaXLi/PUP-7520
(PUP-7520) Update Puppet profiling timers to use monotonic clock
2 parents a812d7c + e0d1778 commit 82ad86e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/puppet/util/profiler/aggregate.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def add_time(time)
7272

7373
class Timer
7474
def initialize
75-
@start = Time.now
75+
@start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
7676
end
7777

7878
def stop
79-
Time.now - @start
79+
Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second) - @start
8080
end
8181
end
8282
end

lib/puppet/util/profiler/wall_clock.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class Timer
2121
FOUR_DECIMAL_DIGITS = '%0.4f'
2222

2323
def initialize
24-
@start = Time.now
24+
@start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
2525
end
2626

2727
def stop
28-
@time = Time.now - @start
28+
@time = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second) - @start
2929
@time
3030
end
3131

0 commit comments

Comments
 (0)