]> granicus.if.org Git - icinga2/commitdiff
Updated dyntest app.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 30 May 2012 12:46:51 +0000 (14:46 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 30 May 2012 12:46:51 +0000 (14:46 +0200)
Makefile.am
configure.ac
dyn/Makefile.am [new file with mode: 0644]
dyntest/Makefile.am [new file with mode: 0644]
dyntest/dyntest.cpp

index ccd79df5db479c788d10915a75d9d23345444deb..7c42f478cc57e124e5d966e02b1c8ad63a9c4436 100644 (file)
@@ -7,6 +7,8 @@ SUBDIRS = \
        compat \
        third-party \
        base \
+       dyn \
+       dyntest \
        jsonrpc \
        icinga \
        components \
index eeab8d6d29ada8542366d6efb374ad15d0eb4ca1..0bee8497d965bfd1740d55e07e30529d16f6efd5 100644 (file)
@@ -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 (file)
index 0000000..2d81360
--- /dev/null
@@ -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 (file)
index 0000000..8dcdc75
--- /dev/null
@@ -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
index 4870d07e8db54f1f9f3e8da8fd9d697d95586bdd..3c4821a86868aeadf2f37ab15a3dab4ee90e6b12 100644 (file)
@@ -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<DynamicObject::Ptr> objects;
+       for (int i = 0; i < num; i++) {
                DynamicObject::Ptr dobj = make_shared<DynamicObject>();
                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>(ObjectSet::GetAllObjects(), &foo);
-       filtered->Start();
+       time(&st);
+       for (vector<DynamicObject::Ptr>::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<Dictionary>();
+       for (int a = 0; a < num_obs; a++) {
+               ObjectSet::Ptr os = make_shared<ObjectSet>(ObjectSet::GetAllObjects(), &foo);
+               os->Start();
+               obs->AddUnnamedProperty(os);
+       }
+       time(&et);
+       cout << "Creating objectsets: " << et - st << " seconds" << endl;
 
+       time(&st);
        ObjectMap::Ptr m = make_shared<ObjectMap>(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;