Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <chrono>
- #include <ctime>
- #define MAX 1000000
- double *g_h = nullptr;
- void bench() {
- double temp_double = 0.0;
- for (int i = 0; i < MAX; i++) {
- g_h[i] = 1.0;
- temp_double = g_h[i];
- }
- }
- int main() {
- g_h = new double[MAX];
- std::chrono::duration<double> elapsed_seconds(0.0);
- std::chrono::time_point<std::chrono::system_clock> start, end;
- start = std::chrono::system_clock::now();
- for (int i = 0; i < 20000; i++) {
- bench();
- }
- end = std::chrono::system_clock::now();
- elapsed_seconds = end-start;
- printf("Total elapsed time: %e. Average time: %e\n", elapsed_seconds.count(), elapsed_seconds.count()/200);
- delete [] g_h;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement