Skip to content

Commit 2b69ffb

Browse files
committed
WIP
1 parent b6dac24 commit 2b69ffb

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

lib/puppet/util.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,10 @@ def symbolizehash(hash)
514514

515515
# Just benchmark, with no logging.
516516
def thinmark
517-
Benchmark.realtime {
518-
yield
519-
}
517+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
518+
yield
519+
stop = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
520+
elapsed = stop - start # elapsed time to execute yield
520521
end
521522

522523
module_function :thinmark

lib/puppet/util/profiler/aggregate.rb

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

spec/unit/transaction/report_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ def add_statuses(count, type = :file)
580580

581581
it 'should sort total at the very end of the time metrics' do
582582
expect(@report.summary).to match(/
583-
Last run: \d+
584583
Transaction evaluation: \d+.\d{2}
584+
Last run: \d+
585585
Total: \d+.\d{2}
586586
Version:
587587
/)

0 commit comments

Comments
 (0)