Bug 18398 – std.datetime.stopwatch documented examples could be better

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-02-08T09:54:40Z
Last change time
2018-05-31T08:16:59Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2018-02-08T09:54:40Z
Someone using `std.datetime.stopwatch` probably wants to use it to obtain a time in milliseconds or some other unit of time but none of the example code on the page involves converting a core.time.Duration. This makes the examples less helpful to a newcomer than they could be. Proposed addition: ```d /// Measure a time in milliseconds, microseconds, or nanoseconds @safe nothrow @nogc unittest { auto sw = StopWatch(AutoStart.no); sw.start(); // ... Insert operations to be timed here ... sw.stop(); long msecs = sw.peek().total!"msecs"; long usecs = sw.peek().total!"usecs"; long nsecs = sw.peek().total!"nsecs"; assert(usecs >= msecs * 1000); assert(nsecs >= usecs * 1000); } ```
Comment #1 by n8sh.secondary — 2018-02-08T10:00:29Z
Comment #2 by github-bugzilla — 2018-02-09T01:22:04Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/602c3ede713e626cc0147f81db24cfaaf426e060 Issue 18398 - std.datetime.stopwatch documented examples could be better https://github.com/dlang/phobos/commit/7c1e10d82f5d71a85fda1a7936751574318739e0 Merge pull request #6139 from n8sh/issue-18398-stopwatch-doc Issue 18398 - std.datetime.stopwatch documented examples could be better merged-on-behalf-of: Sebastian Wilzbach <[email protected]>
Comment #3 by github-bugzilla — 2018-02-11T13:15:57Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/2806ae5e8b2000f0f9de7e1aca6a86b3db995cae Issue 18398 - std.datetime.stopwatch documented examples could be better (x2) Workaround for documentation bug from Issue 16992 https://github.com/dlang/phobos/commit/cecc4cbd5326c669147bd740e8b3b99c766e14b9 Merge pull request #6152 from n8sh/issue-18398-stopwatch-doc-2 Issue 18398 - std.datetime.stopwatch documented examples could be better (x2) merged-on-behalf-of: Jonathan M Davis <[email protected]>
Comment #4 by n8sh.secondary — 2018-05-31T08:16:59Z
This has been fixed but for some reason the issue was open until now.