adding small object benchmark
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@221 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
cdb70a208b
commit
01656e16cc
2 changed files with 246 additions and 0 deletions
49
test/SmallObj/timer.h
Executable file
49
test/SmallObj/timer.h
Executable file
|
@ -0,0 +1,49 @@
|
|||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
|
||||
Timer()
|
||||
{
|
||||
t100 = 0;
|
||||
};
|
||||
|
||||
void start()
|
||||
{
|
||||
t0 = clock();
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
t1 = clock();
|
||||
}
|
||||
|
||||
int t()
|
||||
{
|
||||
return t1-t0;
|
||||
}
|
||||
|
||||
double sec(int t)
|
||||
{
|
||||
return floor(100.0*t/1000.0 )/100;
|
||||
}
|
||||
|
||||
int rel(int t)
|
||||
{
|
||||
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
|
||||
}
|
||||
|
||||
double t100;
|
||||
|
||||
void print(int t, const char* s)
|
||||
{
|
||||
std::cout << s << rel(t) << "%, " << sec(t) << "s " << std::endl;
|
||||
}
|
||||
private:
|
||||
int t0;
|
||||
int t1;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue