Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- using namespace std;
- using namespace std::chrono;
- int main() {
- int intNumber = 32;
- double floatNumber = 32;
- microseconds ms = duration_cast<microseconds>(system_clock::now().time_since_epoch());
- for (long int i = 0; i < 1000000000; i++)
- int num = static_cast<int>(floatNumber) >> 3;
- cout << "Bitshift time on float: " << (duration_cast<microseconds>(system_clock::now().time_since_epoch()) - ms).count() << endl;
- ms = duration_cast<microseconds>(system_clock::now().time_since_epoch());
- for (long int i = 0; i < 1000000000; i++)
- int num = floatNumber / 8;
- cout << "Div time on float : " << (duration_cast<microseconds>(system_clock::now().time_since_epoch()) - ms).count() << endl;
- ms = duration_cast<microseconds>(system_clock::now().time_since_epoch());
- for (long int i = 0; i < 1000000000; i++)
- int num = intNumber >> 3;
- cout << "Bitshift time on int : " << (duration_cast<microseconds>(system_clock::now().time_since_epoch()) - ms).count() << endl;
- ms = duration_cast<microseconds>(system_clock::now().time_since_epoch());
- for (long int i = 0; i < 1000000000; i++)
- int num = intNumber / 8;
- cout << "Div time on int : " << (duration_cast<microseconds>(system_clock::now().time_since_epoch()) - ms).count() << endl;
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment