-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add monotonic_time, system_time and unique_integer to System #4024
Add monotonic_time, system_time and unique_integer to System #4024
Conversation
end | ||
|
||
test "system_time/0" do | ||
assert System.system_time() > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return of this function is spec'ed as integer
, not pos_integer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, right. Good catch!
When using the time API I have found |
correction](http://www.erlang.org/doc/apps/erts/time_correction.html) in the | ||
Erlang docs. | ||
|
||
Inlined by the compiler into `:erlang.system_time/0`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to actually inline all of them.
Actually inlined all the functions. We can't use default args with
As for |
@@ -148,6 +148,13 @@ inline(?system, stacktrace, 0) -> {erlang, get_stacktrace}; | |||
inline(?tuple, to_list, 1) -> {erlang, tuple_to_list}; | |||
inline(?tuple, append, 2) -> {erlang, append_element}; | |||
|
|||
inline(?system, monotonic_time, 0) -> {erlang, monotonic_time}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could move get_stacktrace
inlining into this group as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ordered alphabetically, so it should be before tuple. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this group move there. 😄
+1 for convert_time_unit |
Ok, pushed all the mentioned changes. I removed the explict "see [function] for more information" in the docs as when I say "Inlined by the compiler into We should be good to go! |
I'm wondering, shall we have |
And more important "Determine Order of Events With Time of the Event". |
Add monotonic_time, system_time and unique_integer to System
@lexmag when would use |
@fishcakez to identify the order of events for example, from new time API guide: Time = erlang:monotonic_time(),
UMI = erlang:unique_integer([monotonic]),
EventTag = {Time, UMI}
Thus it's needed to make |
You can't use |
Let's add time_offset as well as it is related to system_time |
I don't follow this bit, can you expand? |
Having this snippet we have proper Order of Events: Time = erlang:monotonic_time(),
UMI = erlang:unique_integer([monotonic]),
EventTag = {Time, UMI} but it doesn't really represent time when the event occurred and thus one can use |
Oh sorry, I thought you were saying can not use |
I think its less explicit as reason that term is there is so we know the system time and not the offset. Though of course the optimisation is nice and makes good sense. I think we need to work on the docs to explain under each function when it is suitable to use it and with examples showing how to combine with other functions. |
Implements #4018.
The implementation is pretty straightforward, I'm just not sure about the docs: should they be more specific? Should they just point to the docs of the functions in the
:erlang
module?(also, is
:erlang.time_unit
ok in the@spec
or should I replicate the type in theSystem
module?)