utfcpp/test_drivers/performance/timer.h
ntrifunovic 7fcdf850d9 Minor improvements to performance testing code
git-svn-id: http://svn.code.sf.net/p/utfcpp/code@115 a809a056-fc17-0410-9590-b4f493f8b08e
2014-06-01 02:07:46 +02:00

22 lines
539 B
C++

#include <ctime>
#include <iostream>
struct timer {
timer(std::ostream& report) : report(report)
{start = std::clock();}
void print_time()
{
using namespace std;
clock_t now = clock();
unsigned milliseconds = (now - start)*1000 / CLOCKS_PER_SEC;
report << "Spent " << milliseconds << "ms here\n";
}
std::clock_t start;
std::ostream& report;
private:
// just to surpress a VC++ 8.0 warning
timer& operator = (const timer&);
timer(const timer&);
};