Advertisement
Guest User

float_abomination_test.p.2

a guest
Feb 27th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <chrono>
  4. #include <cmath>
  5.  
  6. //using real = double;
  7. using real = float;
  8.  
  9. int main() {
  10.     const int numObj = 4096000;
  11.     const real divisor = 2.35;
  12.  
  13.     std::chrono::time_point< std::chrono::high_resolution_clock > start, end;
  14.     start = std::chrono::high_resolution_clock::now();
  15.     for ( int i = 1; i <= numObj; ++i ) {
  16.         real val = static_cast< real >( i );
  17.         val *= val - val / divisor;
  18.         val = sqrt( val ) * val + val / ( divisor * sqrt( val ) );
  19.     }
  20.     end = std::chrono::high_resolution_clock::now();
  21.     std::chrono::duration< double > delta = end - start;
  22.     std::cout << "Elapsed, s: " << delta.count() << std::endl;
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement