Guest User

Untitled

a guest
Nov 30th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.88 KB | None | 0 0
  1. module main;
  2.  
  3. import std.stdio;
  4. import std.algorithm;
  5. import std.range;
  6. import std.bigint;
  7. import std.parallelism;
  8. import std.datetime;
  9.  
  10. class Timer
  11. {
  12.     static SysTime getCount()
  13.     {
  14.         return Clock.currTime();
  15.     }
  16.  
  17.     SysTime starttime;
  18.  
  19.     this() { starttime = getCount(); }
  20.     ~this()
  21.     {
  22.         writefln("elapsed time = %s", getCount() - starttime);
  23.     }
  24. }
  25.  
  26. const base = 100000;
  27.  
  28. int main(string[] args)
  29. {
  30.     BigInt result;
  31.     {
  32.         scope t = new Timer();
  33.         result =
  34.             taskPool.reduce!"a * b"(
  35.                 map!(fold!"cast(std.bigint.BigInt)a * b")
  36.                     (
  37.                         chunks(
  38.                             iota(1, base + 1),
  39.                             base / totalCPUs / 4
  40.                         )
  41.                     )
  42.             );
  43.     }
  44.     writefln("%s", result);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment