diff --git a/Makefile.am b/Makefile.am index ccd79df5d..7c42f478c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,8 @@ SUBDIRS = \ compat \ third-party \ base \ + dyn \ + dyntest \ jsonrpc \ icinga \ components \ diff --git a/configure.ac b/configure.ac index eeab8d6d2..0bee8497d 100644 --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,8 @@ components/configfile/Makefile components/configrpc/Makefile components/demo/Makefile components/discovery/Makefile +dyn/Makefile +dyntest/Makefile icinga/Makefile icinga-app/Makefile jsonrpc/Makefile diff --git a/dyn/Makefile.am b/dyn/Makefile.am new file mode 100644 index 000000000..2d8136059 --- /dev/null +++ b/dyn/Makefile.am @@ -0,0 +1,28 @@ +## Process this file with automake to produce Makefile.in + + +pkglib_LTLIBRARIES = \ + libdyn.la + +libdyn_la_SOURCES = \ + i2-dyn.h \ + dynamicobject.cpp \ + dynamicobject.h \ + objectset.cpp \ + objectset.h \ + objectmap.cpp \ + objectmap.h + +libdyn_la_CPPFLAGS = \ + -DI2_DYN_BUILD \ + $(BOOST_CPPFLAGS) \ + -I${top_srcdir}/base + +libdyn_la_LDFLAGS = \ + $(BOOST_LDFLAGS) \ + -no-undefined \ + @RELEASE_INFO@ \ + @VERSION_INFO@ + +libdyn_la_LIBADD = \ + ${top_builddir}/base/libbase.la diff --git a/dyntest/Makefile.am b/dyntest/Makefile.am new file mode 100644 index 000000000..8dcdc755c --- /dev/null +++ b/dyntest/Makefile.am @@ -0,0 +1,22 @@ +## Process this file with automake to produce Makefile.in + + +bin_PROGRAMS = \ + dyntest + +dyntest_SOURCES = \ + dyntest.cpp + +dyntest_CPPFLAGS = \ + -DI2_DYNTEST_BUILD \ + $(BOOST_CPPFLAGS) \ + -I${top_srcdir}/base \ + -I${top_srcdir}/dyn \ + -I${top_srcdir} + +dyntest_LDFLAGS = \ + $(BOOST_LDFLAGS) + +dyntest_LDADD = \ + ${top_builddir}/base/libbase.la \ + ${top_builddir}/dyn/libdyn.la diff --git a/dyntest/dyntest.cpp b/dyntest/dyntest.cpp index 4870d07e8..3c4821a86 100644 --- a/dyntest/dyntest.cpp +++ b/dyntest/dyntest.cpp @@ -18,19 +18,48 @@ bool foo(const Object::Ptr& object) int main(int argc, char **argv) { - for (int i = 0; i < 1000000; i++) { + int num = atoi(argv[1]); + int num_obs = atoi(argv[2]); + + time_t st, et; + + time(&st); + vector objects; + for (int i = 0; i < num; i++) { DynamicObject::Ptr dobj = make_shared(); dobj->GetConfig()->SetProperty("foo", "bar"); - dobj->Commit(); + objects.push_back(dobj); } + time(&et); + cout << "Creating objects: " << et - st << " seconds" << endl; - ObjectSet::Ptr filtered = make_shared(ObjectSet::GetAllObjects(), &foo); - filtered->Start(); + time(&st); + for (vector::iterator it = objects.begin(); it != objects.end(); it++) { + (*it)->Commit(); + } + time(&et); + cout << "Committing objects: " << et - st << " seconds" << endl; + time(&st); + Dictionary::Ptr obs = make_shared(); + for (int a = 0; a < num_obs; a++) { + ObjectSet::Ptr os = make_shared(ObjectSet::GetAllObjects(), &foo); + os->Start(); + obs->AddUnnamedProperty(os); + } + time(&et); + cout << "Creating objectsets: " << et - st << " seconds" << endl; + + time(&st); ObjectMap::Ptr m = make_shared(ObjectSet::GetAllObjects(), &foogetter); m->Start(); + time(&et); + cout << "Creating objectmap: " << et - st << " seconds" << endl; + time(&st); ObjectMap::Range range = m->GetRange("bar"); + time(&et); + cout << "Retrieving objects from map: " << et - st << " seconds" << endl; cout << distance(range.first, range.second) << " elements" << endl; return 0;