Quantcast
Channel: Measuring the runtime of a C++ code? - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Answer by Kjir for Measuring the runtime of a C++ code?

$
0
0

I used something like this in one of my projects:

#include <sys/time.h>struct timeval start, end;gettimeofday(&start, NULL);//Computegettimeofday(&end, NULL);double elapsed = ((end.tv_sec - start.tv_sec) * 1000) + (end.tv_usec / 1000 - start.tv_usec / 1000);

This is for milliseconds and it works both for C and C++.


Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>