demami
asked on
clock problem for Answer 2000
Here is my problem. How can I modify this code to time the "enter" operation? I'm using the Stopwatch class unmodified to do the timing. I'm looking for the program to print the total time, the average time per "enter" and the min and max time for the "enter"operations.
while (cin>>name)
{
table.enter(name);
}
--------------------------
class Stopwatch
{public:
Stopwatch() : sum (0) {}
void start() {begin = clock();}
double stop() {double res = (double) (clock()-begin);
sum += res;
return res / CLOCKS_PER_SEC;
}
double total() {return sum / CLOCKS_PER_SEC;}
private:
double sum;
clock_t begin;
};
while (cin>>name)
{
table.enter(name);
}
--------------------------
class Stopwatch
{public:
Stopwatch() : sum (0) {}
void start() {begin = clock();}
double stop() {double res = (double) (clock()-begin);
sum += res;
return res / CLOCKS_PER_SEC;
}
double total() {return sum / CLOCKS_PER_SEC;}
private:
double sum;
clock_t begin;
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.