calculate also speed-up factor
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@290 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
4e035929fd
commit
1eb831f009
2 changed files with 25 additions and 5 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// The Loki Library
|
||||||
|
// Copyright (c) 2005 Peter Kümmel
|
||||||
|
// Copyright (c) 2005 Richard Sposato
|
||||||
|
// Permission to use, copy, modify, distribute and sell this software for any
|
||||||
|
// purpose is hereby granted without fee, provided that the above copyright
|
||||||
|
// notice appear in all copies and that both that copyright notice and this
|
||||||
|
// permission notice appear in supporting documentation.
|
||||||
|
// The authors make no representations about the
|
||||||
|
// suitability of this software for any purpose. It is provided "as is"
|
||||||
|
// without express or implied warranty.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//#define LOKI_CLASS_LEVEL_THREADING
|
//#define LOKI_CLASS_LEVEL_THREADING
|
||||||
//#define LOKI_OBJECT_LEVEL_THREADING
|
//#define LOKI_OBJECT_LEVEL_THREADING
|
||||||
|
@ -151,6 +163,8 @@ int main()
|
||||||
int loop = 1000000
|
int loop = 1000000
|
||||||
;
|
;
|
||||||
|
|
||||||
|
std::cout << "\n";
|
||||||
|
|
||||||
Timer t;
|
Timer t;
|
||||||
|
|
||||||
t.t100 = 0;
|
t.t100 = 0;
|
||||||
|
@ -177,9 +191,9 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
t.t100 = 0;
|
t.t100 = 0;
|
||||||
t.t100 = run_new_delete(a,N,loop2,t,"new & delete A on array : ");
|
t.t100 = run_new_delete(a,N,loop2,t,"new & del. A on array: ");
|
||||||
run_new_delete(b,N,loop2,t,"new & delete B on array : ");
|
run_new_delete(b,N,loop2,t,"new & del. B on array: ");
|
||||||
run_new_delete(c,N,loop2,t,"new & delete C on array : ");
|
run_new_delete(c,N,loop2,t,"new & del. C on array: ");
|
||||||
|
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
// Loki::AllocatorSingleton<>::ClearExtraMemory();
|
// Loki::AllocatorSingleton<>::ClearExtraMemory();
|
||||||
|
|
|
@ -29,19 +29,25 @@ public:
|
||||||
|
|
||||||
double sec(int t)
|
double sec(int t)
|
||||||
{
|
{
|
||||||
return floor(100.0*t/1000.0 )/100;
|
return floor(100.0*double(t)/1000.0 )/100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rel(int t)
|
int rel(int t)
|
||||||
{
|
{
|
||||||
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
|
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double speedup(int t)
|
||||||
|
{
|
||||||
|
double tup=t;
|
||||||
|
return (tup!=0 ? floor(100.0*(t100!=0?t100:tup)/tup+0.5)/100 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
double t100;
|
double t100;
|
||||||
|
|
||||||
void print(int t, const char* s)
|
void print(int t, const char* s)
|
||||||
{
|
{
|
||||||
std::cout << s << rel(t) << "%, " << sec(t) << "s " << std::endl;
|
std::cout << s <<"\trelative time: " << rel(t) << "%\tspeed-up factor: " << speedup(t) << "" << std::endl;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
int t0;
|
int t0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue