Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions index.dd
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ void main()
}
----
)
$(EXTRA_EXAMPLE_RUNNABLE Initialize an Array in parallel,
----
void main()
{
import std.datetime, 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].msecs);
writefln("Parallel init: %s msecs", bm[1].msecs);
}
----
)

) $(COMMENT your-code-here)
))) $(COMMENT intro, div, div)
Expand Down