20 lines
391 B
C++
20 lines
391 B
C++
#include "counter.h"
|
|
#include <cstddef>
|
|
#include <iostream>
|
|
#include <sys/time.h>
|
|
|
|
Counter::Counter() {
|
|
}
|
|
|
|
void Counter::start() {
|
|
gettimeofday(&startTime, NULL);
|
|
}
|
|
|
|
long Counter::getTime() {
|
|
gettimeofday(&endTime, NULL);
|
|
long back = (endTime.tv_usec - startTime.tv_usec) / 1000 +
|
|
(endTime.tv_sec - startTime.tv_sec) * 1000;
|
|
this->start();
|
|
return back;
|
|
}
|