diff --git a/test/SmallObj/CompareSmallObj.dev b/test/SmallObj/CompareSmallObj.dev
new file mode 100644
index 0000000..2bf84b1
--- /dev/null
+++ b/test/SmallObj/CompareSmallObj.dev
@@ -0,0 +1,119 @@
+[Project]
+FileName=CompareSmallObj.dev
+Name=CompareSmallObj
+UnitCount=7
+Type=1
+Ver=1
+ObjFiles=
+Includes=C:\Projects\loki\include\loki;C:\Projects\boost_1_33_0
+Libs=
+PrivateResource=
+ResourceIncludes=
+MakeIncludes=
+Compiler=
+CppCompiler=-D LOKI_SMALL_OBJECT_USE_NEW_ARRAY_@@_-D COMPARE_BOOST_POOL_@@_
+Linker=
+IsCpp=1
+Icon=
+ExeOutput=
+ObjectOutput=
+OverrideOutput=0
+OverrideOutputName=CompareSmallObj.exe
+HostApplication=
+Folders=Headers,Sources
+CommandLine=
+UseCustomMakefile=0
+CustomMakefile=
+IncludeVersionInfo=0
+SupportXPThemes=0
+CompilerSet=0
+CompilerSettings=0000001001001000000000
+
+[Unit1]
+FileName=timer.h
+CompileCpp=1
+Folder=Headers
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit2]
+FileName=SmallObjBench.cpp
+CompileCpp=1
+Folder=Sources
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit3]
+FileName=..\..\include\loki\Threads.h
+CompileCpp=1
+Folder=Headers
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit4]
+FileName=..\..\include\loki\Singleton.h
+CompileCpp=1
+Folder=Headers
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit5]
+FileName=..\..\include\loki\SmallObj.h
+CompileCpp=1
+Folder=Headers
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit6]
+FileName=..\..\src\Singleton.cpp
+CompileCpp=1
+Folder=Sources
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit7]
+FileName=..\..\src\SmallObj.cpp
+CompileCpp=1
+Folder=Sources
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[VersionInfo]
+Major=0
+Minor=1
+Release=1
+Build=1
+LanguageID=1033
+CharsetID=1252
+CompanyName=
+FileVersion=
+FileDescription=Developed using the Dev-C++ IDE
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=
+AutoIncBuildNr=0
+
diff --git a/test/SmallObj/CompareSmallObj.vcproj b/test/SmallObj/CompareSmallObj.vcproj
new file mode 100644
index 0000000..8ce0820
--- /dev/null
+++ b/test/SmallObj/CompareSmallObj.vcproj
@@ -0,0 +1,235 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/SmallObj/SmallObjBench.cpp b/test/SmallObj/SmallObjBench.cpp
index 8589b55..7f0bfa1 100755
--- a/test/SmallObj/SmallObjBench.cpp
+++ b/test/SmallObj/SmallObjBench.cpp
@@ -25,6 +25,10 @@
#include
#include
+#ifdef COMPARE_BOOST_POOL
+ #include
+#endif
+
using namespace std;
@@ -44,12 +48,70 @@ struct Base : public ThisIsASmallObject {};
typedef Base
A;
-typedef Base >
+typedef Base< Loki::SmallObject< Loki::SingleThreaded > >
B;
-typedef Base >
+typedef Base< Loki::SmallValueObject< Loki::SingleThreaded > >
C;
+#ifdef COMPARE_BOOST_POOL
+
+class BoostPoolNew
+{
+private:
+ static boost::object_pool< BoostPoolNew > BoostPool;
+
+public:
+ /// Throwing single-object new throws bad_alloc when allocation fails.
+#ifdef _MSC_VER
+ /// @note MSVC complains about non-empty exception specification lists.
+ static void * operator new ( std::size_t )
+#else
+ static void * operator new ( std::size_t ) throw ( std::bad_alloc )
+#endif
+ {
+ return BoostPool.malloc();
+ }
+
+ /// Non-throwing single-object new returns NULL if allocation fails.
+ static void * operator new ( std::size_t, const std::nothrow_t & ) throw ()
+ {
+ return BoostPool.malloc();
+ }
+
+ /// Placement single-object new merely calls global placement new.
+ inline static void * operator new ( std::size_t size, void * place )
+ {
+ return ::operator new( size, place );
+ }
+
+ /// Single-object delete.
+ static void operator delete ( void * p ) throw ()
+ {
+ BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
+ }
+
+ /** Non-throwing single-object delete is only called when nothrow
+ new operator is used, and the constructor throws an exception.
+ */
+ static void operator delete ( void * p, const std::nothrow_t & ) throw()
+ {
+ BoostPool.free( reinterpret_cast< BoostPoolNew * >( p ) );
+ }
+
+ /// Placement single-object delete merely calls global placement delete.
+ inline static void operator delete ( void * p, void * place )
+ {
+ ::operator delete ( p, place );
+ }
+
+};
+
+boost::object_pool< BoostPoolNew > BoostPoolNew::BoostPool;
+
+typedef Base< BoostPoolNew > D;
+#endif
+
/*
class A
{ int i; int* p;};
@@ -61,7 +123,7 @@ class C : public Loki::SmallValueObject<>
template
-int run_new_delete(int loop, Timer& t, char* s)
+int run_new_delete(int loop, Timer& t, const char* s)
{
t.start();
/****************************************************************/
@@ -77,7 +139,7 @@ int run_new_delete(int loop, Timer& t, char* s)
}
template
-int run_new_delete(T** array, int N, int loop, Timer& t, char* s)
+int run_new_delete(T** array, int N, int loop, Timer& t, const char* s)
{
t.start();
/****************************************************************/
@@ -94,7 +156,7 @@ int run_new_delete(T** array, int N, int loop, Timer& t, char* s)
}
template
-int run_new(T** array, int loop, Timer& t, char* s)
+int run_new(T** array, int loop, Timer& t, const char* s)
{
t.start();
/****************************************************************/
@@ -106,7 +168,7 @@ int run_new(T** array, int loop, Timer& t, char* s)
return t.t();
}
template
-int run_delete(T** array, int loop, Timer& t, char* s)
+int run_delete(T** array, int loop, Timer& t, const char* s)
{
t.start();
/****************************************************************/
@@ -120,7 +182,7 @@ int run_delete(T** array, int loop, Timer& t, char* s)
template
-int run_new_delete_array(int N, int loop, Timer& t, char* s)
+int run_new_delete_array(int N, int loop, Timer& t, const char* s)
{
t.start();
/****************************************************************/
@@ -136,7 +198,7 @@ int run_new_delete_array(int N, int loop, Timer& t, char* s)
}
template
-int run_new_array( int N, T** array, int loop, Timer& t, char* s)
+int run_new_array( int N, T** array, int loop, Timer& t, const char* s)
{
t.start();
/****************************************************************/
@@ -148,7 +210,7 @@ int run_new_array( int N, T** array, int loop, Timer& t, char* s)
return t.t();
}
template
-int run_delete_array( T** array, int loop, Timer& t, char* s)
+int run_delete_array( T** array, int loop, Timer& t, const char* s)
{
t.start();
/****************************************************************/
@@ -163,21 +225,29 @@ int run_delete_array( T** array, int loop, Timer& t, char* s)
int main()
-{
- int loop = 1000000
- ;
-
- std::cout << "\n";
-
+{
+ int loop = 1000000;
+
+ cout << "Small-Object Benchmark Tests" << endl;
+ cout << "A = global new and delete \tsizeof(A) =" << sizeof(A) << endl;
+ cout << "B = Loki::SmallObject \tsizeof(B) =" << sizeof(B) << endl;
+ cout << "C = Loki::SmallValueObject\tsizeof(C) =" << sizeof(C) << endl;
+#ifdef COMPARE_BOOST_POOL
+ cout << "D = boost::object_pool \tsizeof(D) =" << sizeof(D) << endl;
+#endif
+ cout << endl << endl;
+
Timer t;
t.t100 = 0;
t.t100 = run_new_delete(loop,t,"new & delete A : ");
run_new_delete(loop,t,"new & delete B : ");
run_new_delete(loop,t,"new & delete C : ");
-
+#ifdef COMPARE_BOOST_POOL
+ run_new_delete(loop,t,"new & delete D : ");
+#endif
+
cout << endl << endl;
-// Loki::AllocatorSingleton<>::ClearExtraMemory();
////////////////////////////////////////////////////////////////////////////////
int N = 100000;
@@ -186,21 +256,29 @@ int main()
A** a = new A*[N];
B** b = new B*[N];
C** c = new C*[N];
+#ifdef COMPARE_BOOST_POOL
+ D** d = new D*[N];
+#endif
for(int i=0; i::ClearExtraMemory();
////////////////////////////////////////////////////////////////////////////////
@@ -208,6 +286,9 @@ int main()
t.t100 = run_new(a,N,t,"new A on array : ");
run_new(b,N,t,"new B on array : ");
run_new(c,N,t,"new C on array : ");
+#ifdef COMPARE_BOOST_POOL
+ run_new(d,N,t,"new D on array : ");
+#endif
cout << endl;
////////////////////////////////////////////////////////////////////////////////
@@ -216,9 +297,11 @@ int main()
t.t100 = run_delete(a,N,t,"delete A on array : ");
run_delete(b,N,t,"delete B on array : ");
run_delete(c,N,t,"delete C on array : ");
+#ifdef COMPARE_BOOST_POOL
+ run_delete(d,N,t,"delete D on array : ");
+#endif
cout << endl << endl;
-// Loki::AllocatorSingleton<>::ClearExtraMemory();
////////////////////////////////////////////////////////////////////////////////
@@ -228,6 +311,9 @@ int main()
t.t100 = run_new_delete_array(N,loop,t,"new & delete [] A : ");
run_new_delete_array(N,loop,t,"new & delete [] B : ");
run_new_delete_array(N,loop,t,"new & delete [] C : ");
+#ifdef COMPARE_BOOST_POOL
+ run_new_delete_array(N,loop,t,"new & delete [] D : ");
+#endif
cout << endl << endl;
////////////////////////////////////////////////////////////////////////////////
@@ -238,6 +324,9 @@ int main()
t.t100 = run_new_array(N,a,count,t,"new [] A on array : ");
run_new_array(N,b,count,t,"new [] B on array : ");
run_new_array(N,c,count,t,"new [] C on array : ");
+#ifdef COMPARE_BOOST_POOL
+ run_new_array(N,d,count,t,"new [] D on array : ");
+#endif
cout << endl;
////////////////////////////////////////////////////////////////////////////////
@@ -246,11 +335,17 @@ int main()
t.t100 = run_delete_array(a,count,t,"delete [] A on array : ");
run_delete_array(b,count,t,"delete [] B on array : ");
run_delete_array(c,count,t,"delete [] C on array : ");
+#ifdef COMPARE_BOOST_POOL
+ run_delete_array(d,count,t,"delete [] D on array : ");
+#endif
delete [] a;
delete [] b;
delete [] c;
+#ifdef COMPARE_BOOST_POOL
+ delete [] d;
+#endif
cout << endl << endl;
Loki::AllocatorSingleton<>::ClearExtraMemory();
@@ -265,6 +360,9 @@ int main()
// ----------------------------------------------------------------------------
// $Log$
+// Revision 1.8 2005/10/26 00:41:00 rich_sposato
+// Added comparison to boost::pool memory allocator.
+//
// Revision 1.7 2005/10/14 18:35:06 rich_sposato
// Added cvs keywords.
//