add CachedFactory, remove gcc warnings

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@722 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2006-10-16 10:30:16 +00:00
parent 8e2c06d853
commit 6f706cff82
3 changed files with 31 additions and 6 deletions

View file

@ -214,7 +214,7 @@ namespace Loki
{
assert(byTime>0);
this->maxCreation = maxCreation;
this->timeValidity = (clock_t)(byTime * CLOCKS_PER_SEC / 1000);
this->timeValidity = static_cast<clock_t>(byTime * CLOCKS_PER_SEC / 1000);
D( cout << "Setting no more than "<< maxCreation <<" creation within " << this->timeValidity <<" ms"<< endl; )
}
};
@ -467,7 +467,7 @@ namespace Loki
{
if(m_vKeys.size()==0)
throw EvictionException();
size_type random = (size_type)((m_vKeys.size()*rand())/(int)(RAND_MAX + 1));
size_type random = static_cast<size_type>((m_vKeys.size()*rand())/int(RAND_MAX + 1));
iterator pos = m_vKeys.begin()+random;
DT& evictKey = *pos;
remove(evictKey);

View file

@ -1,7 +1,7 @@
[Project]
FileName=CachedFactory.dev
Name=Factory
UnitCount=3
UnitCount=5
Type=1
Ver=1
ObjFiles=
@ -77,3 +77,23 @@ Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit4]
FileName=..\..\include\loki\Key.h
CompileCpp=1
Folder=Factory
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit5]
FileName=..\..\include\loki\CachedFactory.h
CompileCpp=1
Folder=Factory
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

View file

@ -1,5 +1,6 @@
#define USE_SEQUENCE
#include <cassert>
#include <iostream>
#include <loki/Factory.h>
@ -12,7 +13,10 @@
#endif
#include <loki/CachedFactory.h>
#include <windows.h>
#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
#endif
using std::cout;
using std::cerr;
@ -96,7 +100,7 @@ bool unitTestCacheOverhead(int loop){
}
elapsedCache = std::clock() - start;
cout << " " << elapsedCache << " ms";
cout << " | average overhead per fetch : " <<(((double)(elapsedCache-elapsedNoCache)) / CLOCKS_PER_SEC * 1000 / loop) << " ms" << endl;
cout << " | average overhead per fetch : " <<((static_cast<double>(elapsedCache-elapsedNoCache)) / CLOCKS_PER_SEC * 1000 / loop) << " ms" << endl;
return true;
}
@ -145,7 +149,8 @@ std::clock_t typicalUse( Cache &CC, unsigned objectKind, unsigned maxObjectCount
vector< AbstractProduct* > fetched;
fetched.reserve(maxObjectCount);
srand(0); // initialise the pseudo random operator
std::clock_t start, end;
std::clock_t start(0);
std::clock_t end(0);
try{
// Registering objects
for(size_t i=0;i<objectKind;i++)