You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example at https://tour.dlang.org/tour/en/gems/functional-programming use a deprecated resources.
If you run it, you will get:
onlineapp.d(38): Deprecation: function onlineapp.main.benchmark!(test).benchmark is deprecated - Use std.datetime.stopwatch.benchmark.
It is not at issue at the moment, std.datetime.benchmark will be removed from the docs in October and from Phobos one year later. TickDuration seems to follow the same plan.
Anyway, a way to rewrite it to avoid those resources is to replace:
import std.datetime : benchmark, to;
by import std.datetime.stopwatch : benchmark;
There are several ways to replace it. The proposal is one that tries to change as little as possible.
Note: the change from 'i' to '_' is of course not necessary (but 'i' is not necessary either).
Do you think the replacement is convenient? If so, do you mind if I send a PR with this one?
The text was updated successfully, but these errors were encountered:
No at all.
Please, there's no need to ask before sending a PR (especially if explaining the change takes longer than sending it). Simply do ;-)
Thanks!
The example at https://tour.dlang.org/tour/en/gems/functional-programming use a deprecated resources.
If you run it, you will get:
onlineapp.d(38): Deprecation: function
onlineapp.main.benchmark!(test).benchmark
is deprecated - Use std.datetime.stopwatch.benchmark.It is not at issue at the moment, std.datetime.benchmark will be removed from the docs in October and from Phobos one year later. TickDuration seems to follow the same plan.
Anyway, a way to rewrite it to avoid those resources is to replace:
import std.datetime : benchmark, to;
by
import std.datetime.stopwatch : benchmark;
and
foreach (i; 0 .. 10) benchmark!test(1)[0] .to!("msecs", double) .reverseArgs!writefln (" took: %.2f miliseconds");
by
foreach (_; 0 .. 10) ( benchmark!test(1)[0] .total!"usecs"/1000.0 ) .reverseArgs!writefln (" took: %.2f miliseconds" );
There are several ways to replace it. The proposal is one that tries to change as little as possible.
Note: the change from 'i' to '_' is of course not necessary (but 'i' is not necessary either).
Do you think the replacement is convenient? If so, do you mind if I send a PR with this one?
The text was updated successfully, but these errors were encountered: