Urara-Blog/node_modules/.pnpm-store/v3/files/78/beaa57a1148cd07f82be9ecfa61b6d4dd2b570b44d0ce6b1612b229f9e22a19dcd78896f7ad8b29dba4d5724f53908456eecaf7ab5f06201ecdef020700d44
2022-08-14 01:14:53 +08:00

18 lines
No EOL
543 B
Text

void main()
{
import std.datetime.stopwatch : benchmark;
import std.math, std.parallelism, std.stdio;
auto logs = new double[100_000];
auto bm = benchmark!({
foreach (i, ref elem; logs)
elem = log(1.0 + i);
}, {
foreach (i, ref elem; logs.parallel)
elem = log(1.0 + i);
})(100); // number of executions of each tested function
writefln("Linear init: %s msecs", bm[0].total!"msecs");
writefln("Parallel init: %s msecs", bm[1].total!"msecs");
}
// From https://dlang.org/