www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12067] New: std.datetime.measureTime() has incomplete example, and does not work

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12067

           Summary: std.datetime.measureTime() has incomplete example, and
                    does not work
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bugzilla digitalmars.com


--- Comment #0 from Walter Bright <bugzilla digitalmars.com> 2014-02-02
20:59:43 PST ---
Presumably the function http://dlang.org/phobos/std_datetime.html#.measureTime
is supposed to be for measuring the elapsed time of some code, i.e. for
benchmarking it. But:

1. The example given is a code fragment, the user is left to guess what else
might be needed to get it to work.

2. The user most likely wants to print the elapsed time. The example gives no
clue how to do that.

3. Guessing at what is needed to make a complete program, the program fails to
link:

-----------------------------
import std.datetime;
import std.stdio;

void main() {
  writeln("benchmark start!");
  {
  auto mt = measureTime!((a){assert(a.seconds);});
  doSomething();
  }
  writeln("benchmark end!");
}
------------------------------
C:\mars>\dmd2\windows\bin\dmd foo
OPTLINK (R) for Win32  Release 8.00.13
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
foo.obj(foo)
 Error 42: Symbol Undefined
_D3foo4mainFZv46__T14__funcliteral1TS4core4time12TickDurationZ14__funcli
teral1FS4core4time12TickDurationZv
--- errorlevel 1

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 02 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12067



--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2014-02-02
21:03:38 PST ---
Forgot to mention, the type of function parameter 'a' needs to be documented.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 02 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12067



--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2014-02-02
22:06:55 PST ---
(In reply to comment #1)
 Forgot to mention, the type of function parameter 'a' needs to be documented.

Jonathan suggested that adding 'TickDuration' as the type of 'a' fixes the linking problem, and indeed it does. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 02 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12067



--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2014-02-02
23:20:39 PST ---
https://github.com/D-Programming-Language/phobos/pull/1903

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 02 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12067



--- Comment #4 from github-bugzilla puremagic.com 2014-02-04 02:01:18 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/6c08a1e526cb1ad0b875876924c7f10d7ca6cfd9
Fix issue 12067.

Note that the measureTime examples do not use documented unittest
blocks, because that doesn't work when the documentation is split out
into a separate version(StdDDoc) section.

https://github.com/D-Programming-Language/phobos/commit/ef000e8150ffaf0030ea5c62c311a23e5067d139
Merge pull request #1907 from jmdavis/12067

Fix issue 12067.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2014