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