Browse Source

Merge branch 'wt-fixes' of https://github.com/RockinRoel/FrameworkBenchmarks into wt-1007

Conflicts:
	toolset/setup/linux/frameworks/wt.sh
Hamilton Turner 11 years ago
parent
commit
961161b82a

+ 35 - 40
frameworks/C++/wt/benchmark.cpp

@@ -40,12 +40,7 @@ public:
 
   template<class Action>
   void persist(Action& a) {
-    // Workaround for issue #783
-    if (a.getsValue()) {
-      Wt::Dbo::field(a, randomNumber, "randomNumber");
-    } else {
-      Wt::Dbo::field(a, randomNumber, "randomnumber");
-    }
+    Wt::Dbo::field(a, randomNumber, "randomnumber");
   }
 };
 
@@ -64,19 +59,19 @@ namespace Wt {
     template<>
     struct dbo_traits<World> : public dbo_default_traits {
       static const char *versionField() {
-	return 0;
+        return 0;
       }
       static IdType invalidId() {
-	return 0;
+        return 0;
       }
     };
     template<>
     struct dbo_traits<Fortune> : public dbo_default_traits {
       static const char *versionField() {
-	return 0;
+        return 0;
       }
       static IdType invalidId() {
-	return 0;
+        return 0;
       }
     };
   }
@@ -88,11 +83,11 @@ public:
         response.setMimeType("application/json");
         response.addHeader("Server", "Wt");
 
-	MyMessage message;
-	message.message = "Hello, World!";
+        MyMessage message;
+        message.message = "Hello, World!";
 
-	Wt::Dbo::JsonSerializer writer(response.out());
-	writer.serialize(message);
+        Wt::Dbo::JsonSerializer writer(response.out());
+        writer.serialize(message);
     }
 };
 
@@ -116,7 +111,7 @@ struct DbStruct {
   DbStruct() : connection("host=INSERT_DB_HOST_HERE port=5432 user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world"),
 #endif
       rng(clock()),
-      distribution(1, 10000) {	       
+      distribution(1, 10000) {
     session.setConnection(connection);
     session.mapClass<World>("world");
     session.mapClass<Fortune>("fortune");
@@ -172,8 +167,8 @@ public:
     if (!db) {
       std::lock_guard<std::mutex> lock(mtx);
       if (!db) {
-	db = new DbStruct();
-	dbStruct_.reset(db);
+        db = new DbStruct();
+        dbStruct_.reset(db);
       }
     }
 
@@ -193,9 +188,9 @@ public:
     if (const std::string *queries = request.getParameter("queries")) {
       n = atoi(queries->c_str());
       if (n < 1)
-	n = 1;
+        n = 1;
       else if (n > 500)
-	n = 500;
+        n = 500;
     } else {
       n = 1;
     }
@@ -207,8 +202,8 @@ public:
     if (!db) {
       std::lock_guard<std::mutex> lock(mtx);
       if (!db) {
-	db = new DbStruct();
-	dbStruct_.reset(db);
+        db = new DbStruct();
+        dbStruct_.reset(db);
       }
     }
 
@@ -241,12 +236,12 @@ public:
   virtual bool conditionValue(const std::string& name) const {
     if (name == "next-fortune") {
       if (it_ == fortunes_->end())
-	it_ = fortunes_->begin();
+        it_ = fortunes_->begin();
       else
-	++it_;
+        ++it_;
 
       if (it_ == fortunes_->end())
-	return false;
+        return false;
 
       return true;
     } else
@@ -275,8 +270,8 @@ public:
     if (!db) {
       std::lock_guard<std::mutex> lock(mtx);
       if (!db) {
-	db = new DbStruct();
-	dbStruct_.reset(db);
+        db = new DbStruct();
+        dbStruct_.reset(db);
       }
     }
 
@@ -306,9 +301,9 @@ public:
     if (const std::string *queries = request.getParameter("queries")) {
       n = atoi(queries->c_str());
       if (n < 1)
-	n = 1;
+        n = 1;
       else if (n > 500)
-	n = 500;
+        n = 500;
     } else {
       n = 1;
     }
@@ -320,8 +315,8 @@ public:
     if (!db) {
       std::lock_guard<std::mutex> lock(mtx);
       if (!db) {
-	db = new DbStructNoTransaction();
-	dbStruct_.reset(db);
+        db = new DbStructNoTransaction();
+        dbStruct_.reset(db);
       }
     }
 
@@ -330,16 +325,16 @@ public:
     for (int i = 0; i < n; ++i) {
       bool success = false;
       while (!success) {
-	try {
-	  Wt::Dbo::Transaction transaction(db->session);
-	  Wt::Dbo::ptr<World> world = db->session.load<World>(db->rand());
-	  world.modify()->randomNumber = db->rand();
-	  transaction.commit();
-	  results.push_back(world);
-	  success = true;
-	} catch (Wt::Dbo::Exception& e) {
-	  // Retry
-	}
+        try {
+          Wt::Dbo::Transaction transaction(db->session);
+          Wt::Dbo::ptr<World> world = db->session.load<World>(db->rand());
+          world.modify()->randomNumber = db->rand();
+          transaction.commit();
+          results.push_back(world);
+          success = true;
+        } catch (Wt::Dbo::Exception& e) {
+          // Retry
+        }
       }
     }
 

+ 2 - 3
frameworks/C++/wt/setup.py

@@ -4,11 +4,10 @@ import setup_util
 
 def start(args, logfile, errfile, cwd='wt'):
     setup_util.replace_text("wt/benchmark.cpp", "INSERT_DB_HOST_HERE", args.database_host);
-    subprocess.check_call('g++ -O3 -DNDEBUG -std=c++0x -L/usr/local/lib -I/usr/local/include -o benchmark.wt benchmark.cpp -lwt -lwthttp -lwtdbo -lwtdbomysql -lboost_thread', shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
-    os.environ['LD_LIBRARY_PATH'] = '/usr/local/lib:' + os.environ.get('LD_LIBRARY_PATH', '.')
+    subprocess.check_call('g++-4.8 -O3 -DNDEBUG -std=c++0x -L${BOOST_LIB} -I${BOOST_INC} -L${WT_LIB} -I${WT_INC} -o benchmark.wt benchmark.cpp -lwt -lwthttp -lwtdbo -lwtdbomysql -lboost_thread', shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
     subprocess.Popen(['./benchmark.wt',
         '-c', 'wt_config.xml',
-        '-t', str(args.max_threads * 4),
+        '-t', str(args.max_threads),
     	'--docroot', '.',
         '--http-address', '0.0.0.0',
         '--http-port', '8080',

+ 2 - 3
frameworks/C++/wt/setup_postgres.py

@@ -4,11 +4,10 @@ import setup_util
 
 def start(args, logfile, errfile, cwd='wt'):
     setup_util.replace_text("wt/benchmark.cpp", "INSERT_DB_HOST_HERE", args.database_host);
-    subprocess.check_call('g++ -O3 -DNDEBUG -DBENCHMARK_USE_POSTGRES -std=c++0x -L/usr/local/lib -I/usr/local/include -o benchmark_postgres.wt benchmark.cpp -lwt -lwthttp -lwtdbo -lwtdbopostgres -lboost_thread', shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
-    os.environ['LD_LIBRARY_PATH'] = '/usr/local/lib:' + os.environ.get('LD_LIBRARY_PATH', '.')
+    subprocess.check_call('g++-4.8 -O3 -DNDEBUG -DBENCHMARK_USE_POSTGRES -std=c++0x -L${BOOST_LIB} -I${BOOST_INC} -L${WT_LIB} -I${WT_INC} -o benchmark_postgres.wt benchmark.cpp -lwt -lwthttp -lwtdbo -lwtdbopostgres -lboost_thread', shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
     subprocess.Popen(['./benchmark_postgres.wt',
         '-c', 'wt_config.xml',
-        '-t', str(args.max_threads * 4),
+        '-t', str(args.max_threads),
     	'--docroot', '.',
         '--http-address', '0.0.0.0',
         '--http-port', '8080',

+ 3 - 1
toolset/setup/linux/frameworks/wt.sh

@@ -33,6 +33,8 @@ fw_untar wt-3.3.3.tar.gz
 cd wt-3.3.3
 mkdir -p build
 cd build
-cmake .. -DWT_CPP_11_MODE=-std=c++0x -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$IROOT/wt
+cmake .. -DWT_CPP_11_MODE=-std=c++0x -DCMAKE_BUILD_TYPE=Release \
+  -DCMAKE_INSTALL_PREFIX=${IROOT}/wt -DCONFIGDIR=${IROOT}/wt/etc \
+  -DCMAKE_CXX_COMPILER=$(which g++-4.8)
 make
 make install

+ 11 - 0
wt/bash_profile.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+export BOOST_ROOT=${IROOT}/boost
+export BOOST_INC=${BOOST_ROOT}/include
+export BOOST_LIB=${BOOST_ROOT}/lib
+
+export WT_ROOT=${IROOT}/wt
+export WT_LIB=${WT_ROOT}/lib
+export WT_INC=${WT_ROOT}/include
+
+export LD_LIBRARY_PATH="${BOOST_LIB}:${WT_LIB}:${LD_LIBRARY_PATH}"