Time Difference

Hi guys!

I have a question: In one of my programmes I want to return the time it's taken the programme to make a calculation.

Right now I have something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <ctime>

time_t Start, End;
double dif;

int main()
{
   // input number
   time (& Start);
   // make calculation
   time (& End);
   dif = difftime (End, Start);
   cout << "Completed calculation in " << dif << " second(s)." << endl; // show how long the calculation has taken
   // make another calculation or exit etc.
}


However, I want the programme to show the time difference in microseconds, since it now only gives 0 seconds, or sometimes 1 (it's not a very hard calculation).

Could somebody please help me?

Greets!
Last edited on
Topic archived. No new replies allowed.