-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Process::CLOCK_MONOTONIC for timing instead of Time.now.to_f.
Work related to #302.
- Loading branch information
1 parent
ab41103
commit 642eff6
Showing
8 changed files
with
76 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Vedeu | ||
|
||
module Logging | ||
|
||
# If the system supports Process::CLOCK_MONOTONIC use that for | ||
# timestamps. | ||
# | ||
# Vedeu.clock_time # => 15217.232113 (Process::CLOCK_MONOTONIC) | ||
# # => 1447196800.3098037 (Time.now) | ||
# | ||
module ClockTime | ||
|
||
if defined?(Process::CLOCK_MONOTONIC) | ||
def self.clock_time | ||
Process.clock_gettime(Process::CLOCK_MONOTONIC) | ||
end | ||
|
||
else | ||
def self.clock_time | ||
Time.now | ||
end | ||
|
||
end | ||
|
||
end # ClockTime | ||
|
||
end # Logging | ||
|
||
# @!method clock_time | ||
# @see Vedeu::Logging::ClockTime | ||
def_delegators Vedeu::Logging::ClockTime, | ||
:clock_time | ||
|
||
end # Vedeu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'test_helper' | ||
|
||
module Vedeu | ||
|
||
module Logging | ||
|
||
describe ClockTime do | ||
|
||
end # ClockTime | ||
|
||
end # Logging | ||
|
||
end # Vedeu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters