Boost logo

Boost-Commit :

From: mconsoni_at_[hidden]
Date: 2007-06-26 15:08:07


Author: mconsoni
Date: 2007-06-26 15:08:05 EDT (Tue, 26 Jun 2007)
New Revision: 7175
URL: http://svn.boost.org/trac/boost/changeset/7175

Log:
- Replaced the tabs for spaces (Boost Guidelines don't allow tabs..).
- Assured that the width is less than 80 columns.

Text files modified:
   sandbox/libs/extension/benchmarks/hello_world_plain_old.cpp | 6
   sandbox/libs/extension/benchmarks/multiple_calls.cpp | 158 +++++++++++++++++----------------
   sandbox/libs/extension/benchmarks/multiple_libraries.cpp | 183 ++++++++++++++++++++++-----------------
   sandbox/libs/extension/benchmarks/plain_old_approach.cpp | 129 ++++++++++++++-------------
   4 files changed, 254 insertions(+), 222 deletions(-)

Modified: sandbox/libs/extension/benchmarks/hello_world_plain_old.cpp
==============================================================================
--- sandbox/libs/extension/benchmarks/hello_world_plain_old.cpp (original)
+++ sandbox/libs/extension/benchmarks/hello_world_plain_old.cpp 2007-06-26 15:08:05 EDT (Tue, 26 Jun 2007)
@@ -1,6 +1,6 @@
 /*
  * Boost.Extension / hello_world_plain_old benchmark
- * hello world plugin implemented in dl* style
+ * hello world plugin implemented in dl* style
  *
  * (C) Copyright Mariano G. Consoni 2007
  * Distributed under the Boost Software License, Version 1.0. (See
@@ -32,6 +32,6 @@
 
 extern "C" void EXPORT_DECL extension_export_words(word **h, word **w)
 {
- *h = new hello;
- *w = new world;
+ *h = new hello;
+ *w = new world;
 }

Modified: sandbox/libs/extension/benchmarks/multiple_calls.cpp
==============================================================================
--- sandbox/libs/extension/benchmarks/multiple_calls.cpp (original)
+++ sandbox/libs/extension/benchmarks/multiple_calls.cpp 2007-06-26 15:08:05 EDT (Tue, 26 Jun 2007)
@@ -1,7 +1,7 @@
 /*
  * Boost.Extension / multiple method class benchmark
- * This benchmark calls a lot of times a method of an implementation
- * (comparing dl* and extensions)
+ * This benchmark calls a lot of times a method of an implementation
+ * (comparing dl* and extensions)
  *
  * (C) Copyright Mariano G. Consoni 2007
  * Distributed under the Boost Software License, Version 1.0. (See
@@ -40,93 +40,99 @@
 
 int main(void)
 {
- using namespace boost::extensions;
+ using namespace boost::extensions;
 
- const unsigned int times = 1000000;
+ const unsigned int times = 1000000;
 
- // boost.extensions style
- boost::timer extensions_style;
- {
- shared_library l((std::string("libHelloWorldLib") + ".extension").c_str());
- l.open();
- {
- factory_map fm;
- functor<void, factory_map &> load_func = l.get_functor<void, factory_map &>("extension_export_word");
- load_func(fm);
-
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
-
- for(unsigned int c = 0; c < times; ++c) {
-
- for (std::list<factory<word, int> >::iterator current_word = factory_list.begin();
- current_word != factory_list.end(); ++current_word)
- {
- std::auto_ptr<word> word_ptr(current_word->create());
-
- // do something with the word
- std::string s(word_ptr->get_val());
- s += "\n";
- }
- }
- }
- l.close();
- }
- std::cout << "Boost.extensions style: " << extensions_style.elapsed() << std::endl;
-
-
- // plain old style
- boost::timer old_style;
- {
+ // boost.extensions style
+ boost::timer extensions_style;
+ {
+ shared_library l((std::string("libHelloWorldLib") + ".extension").c_str());
+ l.open();
+ {
+ factory_map fm;
+ functor<void, factory_map &> load_func = l.get_functor<void,
+ factory_map &>("extension_export_word");
+ load_func(fm);
+
+ std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+
+ for(unsigned int c = 0; c < times; ++c) {
+
+ for (std::list<factory<word, int> >::iterator current_word =
+ factory_list.begin();
+ current_word != factory_list.end();
+ ++current_word) {
+ std::auto_ptr<word> word_ptr(current_word->create());
+
+ // do something with the word
+ std::string s(word_ptr->get_val());
+ s += "\n";
+ }
+
+ }
+ }
+ l.close();
+ }
+ std::cout << "Boost.extensions style: " << extensions_style.elapsed()
+ << std::endl;
+
+
+ // plain old style
+ boost::timer old_style;
+ {
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- HMODULE library = LoadLibrary("libPlainOldHelloWorldLib.extension");
+ HMODULE library = LoadLibrary("libPlainOldHelloWorldLib.extension");
 #else
- void *library = dlopen("libPlainOldHelloWorldLib.extension", RTLD_LAZY);
+ void *library = dlopen("libPlainOldHelloWorldLib.extension", RTLD_LAZY);
 #endif
 
- if(library == 0) {
- std::cerr << "Cannot open Hello World Library." << std::endl;
- return 1;
- }
- {
- typedef void (*export_words_function_type)(word **, word **);
- export_words_function_type export_words;
+ if(library == 0) {
+ std::cerr << "Cannot open Hello World Library." << std::endl;
+ return 1;
+ }
+
+ {
+ typedef void (*export_words_function_type)(word **, word **);
+ export_words_function_type export_words;
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- export_words = (export_words_function_type) GetProcAddress(library, "extension_export_words");
+ export_words =
+ (export_words_function_type) GetProcAddress(library,
+ "extension_export_words");
 #else
- *(void **) (&export_words) = dlsym(library, "extension_export_words");
+ *(void **) (&export_words) = dlsym(library, "extension_export_words");
 #endif
-
- if(export_words == 0) {
- std::cerr << "Cannot get exported symbol." << std::endl;
- return 1;
- }
-
-
- for(unsigned int c = 0; c < times; ++c) {
- // retrieve the words
- word *first_word, *second_word;
- (*export_words)(&first_word, &second_word);
-
- // do something with the word
- std::string f(first_word->get_val());
- f += "\n";
-
- std::string s(second_word->get_val());
- s += "\n";
-
- delete first_word;
- delete second_word;
- }
- }
+
+ if(export_words == 0) {
+ std::cerr << "Cannot get exported symbol." << std::endl;
+ return 1;
+ }
+
+ for(unsigned int c = 0; c < times; ++c) {
+ // retrieve the words
+ word *first_word, *second_word;
+ (*export_words)(&first_word, &second_word);
+
+ // do something with the word
+ std::string f(first_word->get_val());
+ f += "\n";
+
+ std::string s(second_word->get_val());
+ s += "\n";
+
+ delete first_word;
+ delete second_word;
+ }
+ }
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- FreeLibrary(library);
+ FreeLibrary(library);
 #else
- dlclose(library);
+ dlclose(library);
 #endif
- }
- std::cout << "Plain old style: " << old_style.elapsed() << std::endl;
+ }
+ std::cout << "Plain old style: " << old_style.elapsed() << std::endl;
 
- return 0;
+ return 0;
 }

Modified: sandbox/libs/extension/benchmarks/multiple_libraries.cpp
==============================================================================
--- sandbox/libs/extension/benchmarks/multiple_libraries.cpp (original)
+++ sandbox/libs/extension/benchmarks/multiple_libraries.cpp 2007-06-26 15:08:05 EDT (Tue, 26 Jun 2007)
@@ -1,6 +1,6 @@
 /*
  * Boost.Extension / multiple libraries benchmark
- * This benchmark loads a lot of libraries (comparing dl* and extensions)
+ * This benchmark loads a lot of libraries (comparing dl* and extensions)
  *
  * (C) Copyright Mariano G. Consoni 2007
  * Distributed under the Boost Software License, Version 1.0. (See
@@ -44,116 +44,139 @@
 // copy the original library qty times to be loaded in the main routine
 void copy_libraries(const std::string &lib_base, unsigned int qty)
 {
- for(unsigned int i = 1; i <= qty; ++i) {
- std::string library_copy = lib_base + boost::lexical_cast<std::string>(i) + ".extension";
- if(boost::filesystem::exists(lib_base + ".extension") && !boost::filesystem::exists(library_copy)) {
- boost::filesystem::copy_file(lib_base + ".extension", library_copy);
- }
- }
+ for(unsigned int i = 1; i <= qty; ++i) {
+ std::string library_copy = lib_base
+ + boost::lexical_cast<std::string>(i)
+ + ".extension";
+
+ if(boost::filesystem::exists(lib_base + ".extension") &&
+ !boost::filesystem::exists(library_copy)) {
+
+ boost::filesystem::copy_file(lib_base + ".extension", library_copy);
+ }
+ }
 }
 
+
 // remove the libraries after using them
 void remove_libraries(const std::string &lib_base, unsigned int qty)
 {
- for(unsigned int i = 1; i <= qty; ++i) {
- std::string library_copy = lib_base + boost::lexical_cast<std::string>(i) + ".extension";
- if(boost::filesystem::exists(library_copy)) {
- boost::filesystem::remove(library_copy);
- }
- }
+ for(unsigned int i = 1; i <= qty; ++i) {
+ std::string library_copy = lib_base
+ + boost::lexical_cast<std::string>(i)
+ + ".extension";
+
+ if(boost::filesystem::exists(library_copy)) {
+ boost::filesystem::remove(library_copy);
+ }
+ }
 }
 
 
 int main(void)
 {
- using namespace boost::extensions;
+ using namespace boost::extensions;
+
+ unsigned int libs = 500;
+
+ copy_libraries("libHelloWorldLib", libs);
+ copy_libraries("libPlainOldHelloWorldLib", libs);
+
+
+ // boost.extensions style
+ boost::timer extensions_style;
+ for(unsigned int lib_number = 1; lib_number <= libs; ++lib_number) {
+
+ shared_library l(std::string("libHelloWorldLib"
+ + boost::lexical_cast<std::string>(lib_number)
+ + ".extension").c_str());
+
+ l.open();
+ {
+ factory_map fm;
+ functor<void, factory_map &> load_func =
+ l.get_functor<void, factory_map &>("extension_export_word");
+
+ load_func(fm);
+
+ std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ for (std::list<factory<word, int> >::iterator current_word =
+ factory_list.begin(); current_word != factory_list.end();
+ ++current_word) {
 
- unsigned int libs = 500;
+ std::auto_ptr<word> word_ptr(current_word->create());
 
- copy_libraries("libHelloWorldLib", libs);
- copy_libraries("libPlainOldHelloWorldLib", libs);
+ // do something with the word
+ std::string s(word_ptr->get_val());
+ s += "\n";
+ }
+ }
+ l.close();
+ }
+ std::cout << "Boost.extensions style: " << extensions_style.elapsed()
+ << std::endl;
 
 
- // boost.extensions style
- boost::timer extensions_style;
- for(unsigned int lib_number = 1; lib_number <= libs; ++lib_number) {
-
- shared_library l(std::string("libHelloWorldLib" + boost::lexical_cast<std::string>(lib_number) + ".extension").c_str());
- l.open();
- {
- factory_map fm;
- functor<void, factory_map &> load_func = l.get_functor<void, factory_map &>("extension_export_word");
- load_func(fm);
-
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
- for (std::list<factory<word, int> >::iterator current_word = factory_list.begin();
- current_word != factory_list.end(); ++current_word)
- {
- std::auto_ptr<word> word_ptr(current_word->create());
-
- // do something with the word
- std::string s(word_ptr->get_val());
- s += "\n";
- }
- }
- l.close();
- }
- std::cout << "Boost.extensions style: " << extensions_style.elapsed() << std::endl;
-
-
- // plain old style
- boost::timer old_style;
- for(unsigned int lib_number = 1; lib_number <= libs; ++lib_number) {
+ // plain old style
+ boost::timer old_style;
+ for(unsigned int lib_number = 1; lib_number <= libs; ++lib_number) {
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- HMODULE library = LoadLibrary(std::string("libPlainOldHelloWorldLib" + boost::lexical_cast<std::string>(lib_number) + ".extension").c_str());
+ HMODULE library = LoadLibrary(std::string("libPlainOldHelloWorldLib"
+ + boost::lexical_cast<std::string>(lib_number)
+ + ".extension").c_str());
 #else
- void *library = dlopen(std::string("libPlainOldHelloWorldLib" + boost::lexical_cast<std::string>(lib_number) + ".extension").c_str(), RTLD_LAZY);
+ void *library = dlopen(std::string("libPlainOldHelloWorldLib"
+ + boost::lexical_cast<std::string>(lib_number)
+ + ".extension").c_str(), RTLD_LAZY);
 #endif
 
- if(library == 0) {
- std::cerr << "Cannot open Hello World Library (libPlainOldHelloWorldLib" << lib_number << ".extension)" << std::endl;
- return 1;
- }
- typedef void (*export_words_function_type)(word **, word **);
- export_words_function_type export_words;
+ if(library == 0) {
+ std::cerr << "Cannot open Hello World Library (libPlainOldHelloWorldLib"
+ << lib_number << ".extension)" << std::endl;
+
+ return 1;
+ }
+ typedef void (*export_words_function_type)(word **, word **);
+ export_words_function_type export_words;
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- export_words = (export_words_function_type) GetProcAddress(library, "extension_export_words");
+ export_words = (export_words_function_type) GetProcAddress(library,
+ "extension_export_words");
 #else
- *(void **) (&export_words) = dlsym(library, "extension_export_words");
+ *(void **) (&export_words) = dlsym(library, "extension_export_words");
 #endif
 
- if(export_words == 0) {
- std::cerr << "Cannot get exported symbol." << std::endl;
- return 1;
- }
-
- // retrieve the words
- word *first_word, *second_word;
- (*export_words)(&first_word, &second_word);
-
- // do something with the word
- std::string f(first_word->get_val());
- f += "\n";
+ if(export_words == 0) {
+ std::cerr << "Cannot get exported symbol." << std::endl;
+ return 1;
+ }
+
+ // retrieve the words
+ word *first_word, *second_word;
+ (*export_words)(&first_word, &second_word);
+
+ // do something with the word
+ std::string f(first_word->get_val());
+ f += "\n";
 
- std::string s(second_word->get_val());
- s += "\n";
+ std::string s(second_word->get_val());
+ s += "\n";
 
- delete first_word;
- delete second_word;
+ delete first_word;
+ delete second_word;
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- FreeLibrary(library);
+ FreeLibrary(library);
 #else
- dlclose(library);
+ dlclose(library);
 #endif
- }
- std::cout << "Plain old style: " << old_style.elapsed() << std::endl;
+ }
+ std::cout << "Plain old style: " << old_style.elapsed() << std::endl;
 
 
- remove_libraries("libHelloWorldLib", libs);
- remove_libraries("libPlainOldHelloWorldLib", libs);
+ remove_libraries("libHelloWorldLib", libs);
+ remove_libraries("libPlainOldHelloWorldLib", libs);
 
- return 0;
+ return 0;
 }

Modified: sandbox/libs/extension/benchmarks/plain_old_approach.cpp
==============================================================================
--- sandbox/libs/extension/benchmarks/plain_old_approach.cpp (original)
+++ sandbox/libs/extension/benchmarks/plain_old_approach.cpp 2007-06-26 15:08:05 EDT (Tue, 26 Jun 2007)
@@ -38,86 +38,89 @@
 
 int main(void)
 {
- using namespace boost::extensions;
+ using namespace boost::extensions;
 
- const unsigned int times = 1000;
+ const unsigned int times = 1000;
 
- // boost.extensions style
- boost::timer extensions_style;
- for(unsigned int c = 0; c < times; ++c) {
-
- shared_library l((std::string("libHelloWorldLib") + ".extension").c_str());
- l.open();
- {
- factory_map fm;
- functor<void, factory_map &> load_func = l.get_functor<void, factory_map &>("extension_export_word");
- load_func(fm);
-
- std::list<factory<word, int> > & factory_list = fm.get<word, int>();
- for (std::list<factory<word, int> >::iterator current_word = factory_list.begin();
- current_word != factory_list.end(); ++current_word)
- {
- std::auto_ptr<word> word_ptr(current_word->create());
-
- // do something with the word
- std::string s(word_ptr->get_val());
- s += "\n";
- }
- }
- l.close();
- }
- std::cout << "Boost.extensions style: " << extensions_style.elapsed() << std::endl;
-
-
- // plain old style
- boost::timer old_style;
- for(unsigned int c = 0; c < times; ++c) {
+ // boost.extensions style
+ boost::timer extensions_style;
+ for(unsigned int c = 0; c < times; ++c) {
+
+ shared_library l((std::string("libHelloWorldLib") + ".extension").c_str());
+ l.open();
+ {
+ factory_map fm;
+ functor<void, factory_map &> load_func =
+ l.get_functor<void, factory_map &>("extension_export_word");
+ load_func(fm);
+
+ std::list<factory<word, int> > & factory_list = fm.get<word, int>();
+ for (std::list<factory<word, int> >::iterator current_word =
+ factory_list.begin(); current_word != factory_list.end();
+ ++current_word) {
+ std::auto_ptr<word> word_ptr(current_word->create());
+
+ // do something with the word
+ std::string s(word_ptr->get_val());
+ s += "\n";
+ }
+ }
+ l.close();
+ }
+ std::cout << "Boost.extensions style: " << extensions_style.elapsed()
+ << std::endl;
+
+
+ // plain old style
+ boost::timer old_style;
+ for(unsigned int c = 0; c < times; ++c) {
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- HMODULE library = LoadLibrary("libPlainOldHelloWorldLib.extension");
+ HMODULE library = LoadLibrary("libPlainOldHelloWorldLib.extension");
 #else
- void *library = dlopen("libPlainOldHelloWorldLib.extension", RTLD_LAZY);
+ void *library = dlopen("libPlainOldHelloWorldLib.extension", RTLD_LAZY);
 #endif
 
- if(library == 0) {
- std::cerr << "Cannot open Hello World Library." << std::endl;
- return 1;
- }
- typedef void (*export_words_function_type)(word **, word **);
- export_words_function_type export_words;
+ if(library == 0) {
+ std::cerr << "Cannot open Hello World Library." << std::endl;
+ return 1;
+ }
+ typedef void (*export_words_function_type)(word **, word **);
+ export_words_function_type export_words;
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- export_words = (export_words_function_type) GetProcAddress(library, "extension_export_words");
+ export_words = (export_words_function_type) GetProcAddress(library,
+ "extension_export_words");
 #else
- *(void **) (&export_words) = dlsym(library, "extension_export_words");
+ *(void **) (&export_words) = dlsym(library, "extension_export_words");
 #endif
 
- if(export_words == 0) {
- std::cerr << "Cannot get exported symbol." << std::endl;
- return 1;
- }
-
- // retrieve the words
- word *first_word, *second_word;
- (*export_words)(&first_word, &second_word);
-
- // do something with the word
- std::string f(first_word->get_val());
- f += "\n";
+ if(export_words == 0) {
+ std::cerr << "Cannot get exported symbol." << std::endl;
+ return 1;
+ }
+
+ // retrieve the words
+ word *first_word, *second_word;
+ (*export_words)(&first_word, &second_word);
+
+ // do something with the word
+ std::string f(first_word->get_val());
+ f += "\n";
 
- std::string s(second_word->get_val());
- s += "\n";
+ std::string s(second_word->get_val());
+ s += "\n";
 
- delete first_word;
- delete second_word;
+ delete first_word;
+ delete second_word;
 
 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- FreeLibrary(library);
+ FreeLibrary(library);
 #else
- dlclose(library);
+ dlclose(library);
 #endif
- }
- std::cout << "Plain old style: " << old_style.elapsed() << std::endl;
+ }
+ std::cout << "Plain old style: " << old_style.elapsed() << std::endl;
 
- return 0;
+ return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk