add CachedFactory, patches for: msvc, build system
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@720 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
cf3ca512e6
commit
78febe17ec
8 changed files with 522 additions and 452 deletions
|
@ -1,7 +1,7 @@
|
|||
[Project]
|
||||
FileName=CachedFactory.dev
|
||||
Name=Factory
|
||||
UnitCount=2
|
||||
UnitCount=3
|
||||
Type=1
|
||||
Ver=1
|
||||
ObjFiles=
|
||||
|
@ -47,9 +47,6 @@ ProductName=
|
|||
ProductVersion=
|
||||
AutoIncBuildNr=0
|
||||
|
||||
|
||||
|
||||
|
||||
[Unit1]
|
||||
FileName=CachedFactoryTest.cpp
|
||||
CompileCpp=1
|
||||
|
@ -59,3 +56,24 @@ Link=1
|
|||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit2]
|
||||
FileName=..\..\src\SmallObj.cpp
|
||||
CompileCpp=1
|
||||
Folder=Factory
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit3]
|
||||
FileName=..\..\src\Singleton.cpp
|
||||
CompileCpp=1
|
||||
Folder=Factory
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="Factory"
|
||||
Name="CachedFactory"
|
||||
ProjectGUID="{925D5863-2F77-41B7-96F1-CC814762C40F}"
|
||||
RootNamespace="CachedFactory"
|
||||
Keyword="Win32Proj"
|
||||
|
@ -169,17 +169,25 @@
|
|||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\CachedFactoryTest.cpp"
|
||||
RelativePath="..\..\include\loki\CachedFactory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\CachedFactory.h"
|
||||
RelativePath=".\CachedFactoryTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\Key.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\Singleton.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\SmallObj.cpp"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
|
|
@ -106,9 +106,9 @@ void testCacheOverhead(){
|
|||
typedef CachedFactory< AbstractProduct, int, NullType, SimplePointer, AmountLimitedCreation, EvictRandom > CRandomEvict;
|
||||
typedef CachedFactory< AbstractProduct, int, NullType, SimplePointer, AmountLimitedCreation, EvictLRU > CLRUEvict;
|
||||
typedef CachedFactory< AbstractProduct, int, NullType, SimplePointer, AmountLimitedCreation, EvictAging > CAgingEvict;
|
||||
bool test1 = dispResult("Random policy", unitTestCacheOverhead< CRandomEvict >(loop));
|
||||
bool test2 = dispResult("LRU policy", unitTestCacheOverhead< CLRUEvict >(loop));
|
||||
bool test3 = dispResult("Aging policy", unitTestCacheOverhead< CAgingEvict >(loop));
|
||||
bool test1 = dispResult("Random policy", unitTestCacheOverhead< CRandomEvict >(loop));(void)test1;
|
||||
bool test2 = dispResult("LRU policy", unitTestCacheOverhead< CLRUEvict >(loop));(void)test2;
|
||||
bool test3 = dispResult("Aging policy", unitTestCacheOverhead< CAgingEvict >(loop));(void)test3;
|
||||
}
|
||||
void unitTestCachePerformance(int loop){
|
||||
typedef CachedFactory< AbstractProduct, int > CCache;
|
||||
|
@ -148,7 +148,7 @@ std::clock_t typicalUse( Cache &CC, unsigned objectKind, unsigned maxObjectCount
|
|||
std::clock_t start, end;
|
||||
try{
|
||||
// Registering objects
|
||||
for(int i=0;i<objectKind;i++)
|
||||
for(size_t i=0;i<objectKind;i++)
|
||||
CC.Register(i, createProductNull);
|
||||
// Simulating real use
|
||||
start = std::clock();
|
||||
|
@ -312,6 +312,7 @@ bool testRelease(){
|
|||
AbstractProduct *pProduct = NULL;
|
||||
CC.ReleaseObject(pProduct);
|
||||
cout << "Caching failed" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -397,7 +398,7 @@ void reliabilityTests()
|
|||
dispText("One or more test have failed");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int , char **)
|
||||
{
|
||||
try{
|
||||
performanceTests();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include ../Makefile.common
|
||||
|
||||
BIN := Factory$(BIN_SUFFIX)
|
||||
SRC := Factory.cpp
|
||||
BIN := CachedFactoryTest$(BIN_SUFFIX)
|
||||
SRC := CachedFactoryTest.cpp
|
||||
OBJ := $(SRC:.cpp=.o)
|
||||
|
||||
.PHONY: all clean
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
cl -c -Zm200 -O2 -DNDEBUG -MT -EHsc -GR -W4 -wd4710 -I"." -I"..\..\include" CachedFactoryTest.cpp.cpp
|
||||
cl -c -Zm200 -O2 -DNDEBUG -MT -EHsc -GR -W4 -wd4710 -I"." -I"..\..\include" CachedFactoryTest.cpp
|
||||
|
||||
link /NOLOGO /SUBSYSTEM:CONSOLE /incremental:no /OUT:"main-msvc.exe" ..\..\lib\loki.lib CachedFactoryTest.cpp.obj
|
||||
link /NOLOGO /SUBSYSTEM:CONSOLE /incremental:no /OUT:"main-msvc.exe" ..\..\lib\loki.lib CachedFactoryTest.obj
|
||||
|
||||
del *.obj
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue