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



20:59:43 PST ---

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




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




22:06:55 PST ---

 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




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




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


Fix issue 12067.

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