Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <chrono>
  3. #include <ctime>
  4. #include <thread>
  5.  
  6. #define n 625000000
  7.  
  8. using namespace std;
  9.  
  10.  
  11. long double sum = 0;
  12. void summa(/*long long &n*/) {
  13.     for (long long i = 1; i < n; i++) {
  14.  
  15.         sum += (i&1 == 0 ? 1 : -1)*log(i) / i;
  16.     }
  17. }
  18. int main()
  19. {
  20. //  long long n = 62500000000;
  21.     std::chrono::time_point<std::chrono::system_clock> start, end;
  22.     start = std::chrono::system_clock::now();
  23.     summa(/*n*/);
  24.     end = std::chrono::system_clock::now();
  25.  
  26.     int elapsed_seconds =
  27.  
  28. std::chrono::duration_cast<std::chrono::milliseconds>
  29.         (end - start).count();
  30.     std::time_t end_time = std::chrono::system_clock::to_time_t(end);
  31.     cout << sum << endl;
  32.     std::cout << "finished computation at " << std::ctime(&end_time)
  33.         << "elapsed time: " << elapsed_seconds << "ms\n";
  34.  
  35.     return 0;
  36. }
  37.  
  38. /*
  39. вариант 5
  40. O2/:
  41.  
  42. x86:
  43. 26455 - debug
  44. 6987 - release
  45.  
  46.  
  47. x64:
  48. 20984 - debug
  49. 4234 - release
  50.  
  51.  
  52.  
  53. intel compiler release:
  54. x86 - 11305
  55. x64 - 3239
  56.  
  57.  
  58. O1/:
  59. x86 - 17543
  60. x64 - 5032
  61.  
  62.  
  63. O3/:
  64. x86 - 11253
  65. x64 - 3258
  66.  
  67. avx:
  68. x86 - 8012
  69. x64 - 3312
  70.  
  71. parall:
  72. x86 - 2136
  73. x64 - 539
  74.  
  75.  
  76. загрузка процессора - 25%
  77. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement