Measure time (#706)

* Create measure_time_elapsed.cpp

* add functionality to measure time elapsed of a code

* cout --> std:cout

* Update measure_time_elapsed.cpp

* Update time_elapsed.cpp

* Update measure_time_elapsed.cpp

* std:cout << getTimeInMicroseconds() - starttime;

* std:cout << getTimeInMicroseconds() - starttime;

* Update measure_time_elapsed.cpp

* Fix include order and use int64

* Remove trailing whitespace

* Delete time_elapsed.cpp

* int64_t

* #include <sys/time.h>

* long long

* int64

* int64_t

* __int64_t

* std::cout and std::nullptr

* #include <iostream>

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Siddharth M 2020-03-01 20:17:32 +05:30 committed by GitHub
parent 2f70c92e75
commit ca068e5828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,19 @@
// To calculate the time taken by a code to execute
#include <sys/time.h>
#include <iostream>
__int64_t getTimeInMicroseconds() {
struct timeval start;
gettimeofday(&start, NULL);
return start.tv_sec * 1000000 + start.tv_usec;
}
// write function sample(args)
int main() {
// write code
__int64_t starttime = getTimeInMicroseconds();
// sample(args) function run
// Any other functions (if present) run
std::cout << getTimeInMicroseconds() - starttime;
}