Updated dyntest app.

This commit is contained in:
Gunnar Beutner 2012-05-30 14:46:51 +02:00
parent 8144ca398b
commit 195cd07ace
5 changed files with 87 additions and 4 deletions

View File

@ -7,6 +7,8 @@ SUBDIRS = \
compat \
third-party \
base \
dyn \
dyntest \
jsonrpc \
icinga \
components \

View 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

28
dyn/Makefile.am Normal file
View File

@ -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

22
dyntest/Makefile.am Normal file
View File

@ -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

View 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;