Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptime: Deprecate the library in the distribution #18858
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc #18585, one less crate to worry about! |
ghost
reviewed
Nov 11, 2014
| @@ -135,6 +135,14 @@ impl Duration { | |||
| Duration { secs: secs, nanos: nanos as i32 } | |||
| } | |||
|
|
|||
| /// Runs a closure, returning the duration of time it took to run the | |||
| /// closure. | |||
| pub fn span(f: ||) -> Duration { | |||
This comment has been minimized.
This comment has been minimized.
ghost
Nov 11, 2014
I wouldn't want to block this PR on this but I think it'd be better for span to take a closure that returns T and return a tuple of (Duration, T) to make it more general-purpose. It'd certainly make it easier to avoid the extra mutable variables that are introduced at this function's call sites in this PR.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Nov 11, 2014
Author
Member
Yeah that would definitely help out those use cases, but I figured that it would be slightly odd to have to worry about the tuple afterwards. I think it may be the right way to go though, it seemed to come up more often than I anticipated!
This comment has been minimized.
This comment has been minimized.
ghost
commented
Nov 11, 2014
|
As you're saying we'll tweak the interface with unboxed closures anyway, at which point we can make the suggested change. |
alexcrichton
force-pushed the
alexcrichton:remove-time
branch
from
5ed19a0
to
4f63687
Nov 12, 2014
bors
added a commit
that referenced
this pull request
Nov 12, 2014
alexcrichton
force-pushed the
alexcrichton:remove-time
branch
from
4f63687
to
a90f44c
Nov 12, 2014
bors
added a commit
that referenced
this pull request
Nov 12, 2014
alexcrichton
force-pushed the
alexcrichton:remove-time
branch
from
a90f44c
to
fcd05ed
Nov 12, 2014
This comment has been minimized.
This comment has been minimized.
|
r=jakub- |
This comment has been minimized.
This comment has been minimized.
|
saw approval from jakub |
This comment has been minimized.
This comment has been minimized.
|
merging alexcrichton/rust/remove-time = fcd05ed into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
fast-forwarding master to auto = 5745e41 |
bors
added a commit
that referenced
this pull request
Nov 12, 2014
bors
closed this
Nov 13, 2014
bors
merged commit fcd05ed
into
rust-lang:master
Nov 13, 2014
2 checks passed
ben0x539
referenced this pull request
Nov 13, 2014
Closed
std::time::duration::Duration::span() is backwards #18925
This was referenced Nov 13, 2014
alexcrichton
deleted the
alexcrichton:remove-time
branch
Nov 20, 2014
This comment has been minimized.
This comment has been minimized.
|
fyi @alexcrichton i think this multiply is overflowing. In all branches; its just that the arithmetic-overflow branch is now catching it happening. Obviously the multiply does not live here anymore; it has AFAICT been migrated to std::sys::windows::time The only evidence I have currently of the overflow is here: try build log
|
This comment has been minimized.
This comment has been minimized.
|
BTW I mention this only because I thought it was an interesting instance of overflow cropping up. I am using the following reformulation to avoid the overflow (hopefully): pnkfelix@b6d2ccb But I would be curious to know your thoughts as to what possible fallout there is from the overflow here. I have not yet attempted to observe how much it may or may not be messing up the result of |
This comment has been minimized.
This comment has been minimized.
|
cc #22788 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
It looks like @vadimcn's approach is just to divide before doing the multiply; this certainly avoids the overflow, but also throws away information. I believe my technique avoids losing the least significant digits in a portable way. |
This comment has been minimized.
This comment has been minimized.
|
(I apologize, the previous comment was written before i had had my first cup of coffee. :( ) |
alexcrichton commentedNov 10, 2014
This commit deprecates the entire libtime library in favor of the
externally-provided libtime in the rust-lang organization. Users of the
libtimecrate as-is today should add this to their Cargo manifests:To implement this transition, a new function
Duration::spanwas added to thestd::time::Durationtime. This function takes a closure and then returns theduration of time it took that closure to execute. This interface will likely
improve with
FnOnceunboxed closures as moving in and out will be a littleeasier.
Due to the deprecation of the in-tree crate, this is a:
[breaking-change]
cc #18855, some of the conversions in the
src/test/bencharea may have been alittle nicer with that implemented