Benchmark block
Jonathan via Digitalmars-d
digitalmars-d at puremagic.com
Tue Mar 31 10:05:39 PDT 2015
> Would this do what you're after?
>
> version(benchmark) {
> unittest {
> import std.conv : to;
> int a;
> void f() {auto b = to!string(a);}
> auto r = benchmark!(f)(10_000);
> auto f0Result = to!Duration(r[0]);
> writeln(f0Result)
> }
> }
>
> rdmd -main -- -version=benchmark -unittest myapp.d
Well, I don't consider benchmarks <a kind of> unit test. So maybe
just this:
version(benchmark) {
import std.conv : to;
int a;
void f() {auto b = to!string(a);}
auto r = benchmark!(f)(10_000);
auto f0Result = to!Duration(r[0]);
writeln(f0Result)
}
rdmd -main -- -version=benchmark myapp.d
More information about the Digitalmars-d
mailing list