Summary: std.datetime StopWatch (and perhaps benchmark)
                    examples need a small fix
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos

--- Comment #0 from Andrej Mitrovic <> 2011-03-29 
17:12:24 PDT ---
The example code for StopWatch has this line:
sw.peek().msec, "[ms]");

This doesn't compile. This should be:
sw.peek().to!("msecs", int), "[ms]");


benchmark's description of the return value:
An array of n uints. Element at slot i contains the number of msecs spent in
calling the ith function times times. "

But the slot at i contains a TickDuration, not 'number of milliseconds'. You
still have to use to!("timemagnitude", returntype") to convert it to
milliseconds if you want to. E.g.:

    auto r = benchmark!(f0, f1, f2)(10_000_000);
    writeln( r[0].to!("msecs", int) );

Could you add that last line? It would really help in understanding the
example. Either that or add nice foreach loop like so:
    auto r = benchmark!(f0, f1, f2)(10_000_000);
    foreach (duration; r)
        writeln(!("msecs", int) );

A mention that TickDuration is defined in core.time would also be useful (it
took me a while to figure out where to find it).

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to