2006-08-11 21:42:05 +00:00
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
|
|
|
struct timer {
|
|
|
|
timer(std::ostream& report) : report(report)
|
|
|
|
{start = std::clock();}
|
2010-09-04 16:10:35 +00:00
|
|
|
|
|
|
|
void print_time()
|
2006-08-11 21:42:05 +00:00
|
|
|
{
|
|
|
|
using namespace std;
|
2010-09-04 16:10:35 +00:00
|
|
|
clock_t now = clock();
|
|
|
|
unsigned milliseconds = (now - start)*1000 / CLOCKS_PER_SEC;
|
2009-07-01 11:55:37 +00:00
|
|
|
report << "Spent " << milliseconds << "ms here\n";
|
|
|
|
}
|
2006-08-11 21:42:05 +00:00
|
|
|
|
|
|
|
std::clock_t start;
|
|
|
|
std::ostream& report;
|
2006-09-07 02:47:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// just to surpress a VC++ 8.0 warning
|
2009-07-01 11:55:37 +00:00
|
|
|
timer& operator = (const timer&);
|
2010-09-04 16:10:35 +00:00
|
|
|
timer(const timer&);
|
2006-08-11 21:42:05 +00:00
|
|
|
};
|