OK so im measuring how much time on some part of my program and it only shows me microseconds. i want to know how can i change this so it would give me seconds
something like this "1.0325 second its what i want, not 1035000 microseconds
any help will be appreciated.

also when i try to divide it by 100000 to get seconds i get 1s, which is not what i want

gettimeofday(&tv1, &tz1); //initializes time set                              

  for (int i = 0; i < times;i++)
    {
// do something
}
  gettimeofday(&tv2, &tz2); // finilizes time set                               

  totalT = (tv2.tv_sec - tv1.tv_sec) * 1000000
    + (tv2.tv_usec - tv1.tv_usec);

   cout << "total time : " << totalT << "us" << endl;

Divide by 1000.0

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.