Skip to content

Instantly share code, notes, and snippets.

@skejeton
Created October 2, 2018 20:21
Show Gist options
  • Save skejeton/f6a1ead2856ceb354f40d6eeab684ce0 to your computer and use it in GitHub Desktop.
Save skejeton/f6a1ead2856ceb354f40d6eeab684ce0 to your computer and use it in GitHub Desktop.
// Example program
#include <iostream>
#include <cmath>
#include <chrono>
int main()
{
float test;
std::chrono::time_point<std::chrono::system_clock> start, end; //Clock
start = std::chrono::system_clock::now();
for (unsigned int i = 0; i < 4294967295; i++)
{
test = sqrt(i);
}
end = std::chrono::system_clock::now();
float elapsed_seconds = std::chrono::duration_cast<std::chrono::milliseconds>
(end-start).count(); //calculate elapsed seconds
std::cout << test << std::endl;
std::cout << elapsed_seconds / 1000 << std::endl;
start = std::chrono::system_clock::now();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment