KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I wish to calculate the time it took for an API to return a value. The time taken for such an action is in the space of nanoseconds. As the API is a C++ class/function, I am using the timer.h to calculate the same: #include <ctime> #include <iostream> using namespace std; int main(int argc, char** argv) { clock_t start; double diff; start = clock(); diff = ( std::clock() - start ) / (double)CLOCKS_PER_SEC; cout<<"printf: "<< diff <<'\n'; return 0; } The above code gives the time in seconds. How do I get the same in nano seconds and with more precision?
Tags (comma-separated)
Save Edits
Cancel